Pragmatism in the real world

A primer on PHP namespaces

I know that there are a lot of posts now about namespaces in PHP 5.3. This is mine which is how I learnt how they work. What are namespaces? From the PHP manual: namespaces are a way of encapsulating items Hardly the most useful of definitions, but it's a starting point! A namespace is a way of grouping code that exists across multiple files without having a naming collision. That is, you can have the… continue reading.

Setting up PHP & MySQL on OS X 10.7 Lion

With OS X 10.7, Apple continues to ship PHP 5.3 with PEAR, GD and PDO_MYSQL out of the box. This is how to set it up from a clean install of 10.7. /usr/local Ensure that the following directories exist: sudo mkdir /usr/local/include sudo mkdir /usr/local/bin sudo mkdir /usr/local/lib sudo mkdir -p /usr/local/man/man1 MySQL Download the 64bit DMG version of MySQL 5.1.x (or 5.5.x) for OS X 10.6 from mysql.com and install the pkg, the startup… continue reading.

Great PHP developer required in Central Birmingham

Update: This position has now been filled. So… we seem to be in the same position as everyone else and are looking to hire a new, great, PHP developer! From the spec: Big Room Internet are looking for a great PHP software engineer to bring depth to the team and spearhead our future development. You will be working across a range of projects, ideally with experience in seeing through a project from start to finish.… continue reading.

Displaying an RSS feed in WordPress

My wife decided that she wanted to display a list of her latest AudioBoos in the sidebar of her blog. She looked at the AudioBoo JavaScript widget but decided it wasn't subtle enough and so she enlisted me to solve her problem. It turns out that AudioBoo has an RSS feed, so a simple plugin was required. I had a quick look on the extension site, but most are now "widgets" which her theme isn't… continue reading.

PHP 5.3 is quicker than PHP 5.2

I know that everyone already knows this, but I happened to find out for myself recently! I was looking at the way view helpers work in ZF2 and thought it would be more convenient if we altered the syntax a little. A side-effect of the change was that we'd have to use call_user_func_array, which is perceived as slow. I thought I'd whip up a simple test to find out how much slower it would be… continue reading.

Some notes on SQL Server blobs with sqlsrv

I recently updated my use of SQL Server with Zend_Db_Adapter_Sqlsrv to use UTF-8 throughout. This turned out to be easy enough: Use ntext, nvarchar types in the database add: resources.db.params.driver_options.CharacterSet = "UTF-8" to your application.ini I subsequently noticed a problem with storing binary data to a varbinary(max) field. The error was: An error occurred translating string for input param 2 to UCS-2: No mapping for the Unicode character exists in the target multi-byte code page.… continue reading.

SqlSrv v2 and long field names

A good proportion of the projects my company undertakes end up on Windows servers with IIS and SQL Server and hence we use the SqlSrv PHP extension from Microsoft. We don't host any of these projects ourselves and leave it up to the client's IT department. This is the main reason that we use a database abstraction layer, Zend_Db, in our case as we can swap the underlying database out with less hassle. A couple… continue reading.

On Exceptions

I've been reading the Proposal for Exceptions in ZF2 and like it. One thing that caught my attention was that it suggests that you can catch an interface. I hadn't heard of that ability before, so I pulled out my trusty text editor to have a play. Consider this code: <?php namespace My; interface ExceptionInterface {} class SplExceptionClass extends InvalidArgumentException implements ExceptionInterface {} class ExceptionClass extends Exception implements ExceptionInterface {} class A { static function… continue reading.

MongoDB on OS X with the stock PHP installation

MongoDB was mentioned a few times at tek and I said that I wanted to have a look at. Travis' article, MongoDB: A first look, came out a few days ago and piqued my interest further. Then Matthew sent me some source code that requires it. The stage was set for getting MongoDB working on my Mac. MongoDB I use homebrew as a package manager for installing open source bits and bobs like couchdb, git,… continue reading.

Sending a file to IE using SSL

I keep coming across this one, so I'm noting it here so I can find it again. Internet Explorer doesn't like certain headers related to caching when you send it a file from an SSL site. The Microsoft knowledge base article, Internet Explorer is unable to open Office documents from an SSL Web site explains the problem quite well: When you attempt to open or download a Microsoft Office document (.doc file, .xls file, .ppt… continue reading.