Pragmatism in the real world

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.

Redirecting email whilst developing

One common problem whilst developing is that you don't want to send emails out to the client (or their clients!). Ideally, we want to alter our development environment so that this doesn't happen, but still allows us to test the contents of emails that are sent by our web applications. Windows On Windows, the mail() function uses SMTP over port 25. Unless you've changed your php.ini file, then it will try to connect to localhost… continue reading.

PHP Advent 2009: On deployment

This year I was asked to write an article for PHP Advent 2009 an it's now been published! Automate your Deployment is a look at how to automate the process of deploying your application to the web server. At my company we started automating our deployment systems just over a year and the number of issues we have around deployment of new code to a website has dropped considerably and is no longer a stressful… continue reading.

Setting up PHP & MySQL on OS X 10.6 Snow Leopard

(Updated 1st May 2010) With OS X 10.6, Apple ships PHP 5.3 with PEAR, GD and PDO_MYSQL out of the box. Also, everything is now 64bit. This means that the entire effort required to get a working PHP dev environment for my work is now much easier. /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… continue reading.

Some notes on Zend Server CE for Mac OS X

I've installed Zend Server CE on my Mac to see where it's got to and it's looking quite usable. The installation puts everything into the usr/local/zend directory which is fairly well laid out so that you can find what you are looking for. There's also a a nice admin system at http://localhost:10081 which allows you to restart PHP, view phpinfo(), configure extensions and php.ini. There's also a phpMyAdmin to help administer the bundled MySQL server.… continue reading.

UTF-8, PHP and MySQL

Everyone else probably already knows this stuff, but I hit an issue today to that took a while to sort out. Fortunately, some kind folks on IRC helped me, but as it's embarrassing to ask for help on the same issue twice, I'm writing down what I've learned! The problem Get a £ character stored to MySQL, retrieved and then displayed without any weird characters in front of it using UTF-8. The solution Make sure… continue reading.

Setting up PHP on OS X Leopard

In the vein of some of Lorna's articles, this is more a note for myself than anything else. Not everything is explained in detail as it assumes you know how to use a command line… These are the steps I take to get the Apple supplied PHP working with GD, PDO_MySQL and Xdebug working on OS X 10.5. /usr/local Ensure that the following directories exist: sudo mkdir /usr/local/include sudo mkdir /usr/local/bin sudo mkdir /usr/local/lib sudo… continue reading.