Another year is over, and as is becoming a tradition, I like to show off some photos that recap my year!\ January We started the year with a visit to the zoo! There was also snowy weather last January and on the last day of the month, we put our house on the market. We would be accepting an offer on it in late October. February In February, I took pictures of canal boats. The… continue reading.
If you have a Zend Framework Front Controller plugin which throws an exception, then the action is still executed and then the error action is then called, so that the displayed output shows two actions rendered, with two layouts also rendered. This is almost certainly not what you want or what you expected. This is how to handle errors in a Front Controller plugin: Prefer preDispatch() over dispatchLoopStartup() as it is called from within the… continue reading.
I came across a situation last week where I needed to access a view helper that was in the default module's views/helpers directory when I was in another module. This came about because my layout.phtml uses a view helper that is in application/views/helpers. By default, it doesn't work and you get an error along the lines of:
Plugin by name 'LoggedInAs' was not found in the registry; used paths:
The fix is simple enough. All you need to do is add this line to your application.ini… continue reading.
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.
A friend of mine recently had a requirement where she wanted to have two config files loaded into Zend_Application, so that the specific settings for the server were not stored in the version control system. Hence she has two config files: application.ini and local.ini where local.ini is different on each server. Update: As takeshin points out with ZF 1.10 or later, an easier solution to this is to pass both ini files into Zend_Application: $application… continue reading.
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.
I'm sure everyone else already knows this, but I've recently discovered that Zend_Validate_PostCode doesn't work with UK postcodes unless you first remove the space between the first and second parts. This is due to a bug in the underlying regular expresssions that are provided by CLDR. It's easy enough to add a filter to remove the space, but I'm a little worried that when (and if) it gets fixed, will the fixed version Zend_Validate_PostCode then… continue reading.
I discovered recently that Zend Framework 1's Zend_Date has two operating modes when it comes to format specifiers: iso and php, where iso is the default. When using Zend_Validate_Date in forms, I like to use the php format specifiers as they are what I'm used to and so can easily know what they mean when reviewing code that I wrote months ago. My code looks something like this: $subForm->addElement('text', 'start_date', array( 'filters' => array('StringTrim', 'StripTags'),… continue reading.
I'm delighted to be able to announce that I'm speaking at the PHPBenelux Conference on 28 & 29 January 2011 in Antwerp, Belgium. This is a community run conference organised by the PHPBenelux user group and given the list of speakers, I'm expecting to learn a lot. The full list of talks is on their website and shows that this is going to be a great conference. I'll be giving a talk that will introduce… continue reading.
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.