Pragmatism in the real world

2008 in pictures

Everyone appears to do end-of-year wrap-up posts about this time of year, so I thought I would do one too… January We started the year with a trip to the zoo. I attempted to get a photo of a waterfall with that blurry water you see the good photographers do. February The highlight of February was talking at the UK PHP Conference in London. March A quiet month with most weekends doing something with the… continue reading.

On models in a Zend Framework application

Let's talk about writing models that communicate with databases within a Zend Framework application. It's a popular topic at the moment as there's been a few threads recently on the ZF mailing lists about creating models. The "is a" relationship When working with models within Zend Framework, the simplest solution is to extend Zend_Db_Table_Abstract and Zend_Db_Table_Row_Abstract along these lines: class Users extends Zend_Db_Table_Abstract { protected $_name = 'users'; protected $_rowClass = 'User'; public function fetchAllInLastNameOrder()… continue reading.

Zend Framework in Action Errata

Note that ZFiA was written for version 1.5 of Zend Framework. If you are using version 1.8 or later, then please read this article on Zend Loader. This is a list of issues that we are aware of: Chapter 2 On page 18, the right hand bracket in the first paragraph is not needed. On page 38, in the last code block, the first line of the method should be: $cutOff = date('Y-m-d', strtotime('-3 months'));… continue reading.

File uploads with Zend_Form_Element_File

Now that Zend Framework 1.7 has been released, I thought I'd take a look at the built in file upload element, Zend_Form_Element_File, and see how it can be used. This is how to use it in its most basic form. I decided to use the same set of form elements as before in order to make things easy. Let's start with the form: The form We extend Zend_Form and store it in the application/forms folder… continue reading.

PHPNW08 Conference

PHPNW 08 took place last Saturday, and even though I wasn't too well, I had a great time. I thought my talk went okay, and judging from the feedback, at least some people learnt something from it which is good. I hope that the tongue-in-cheek references to my book were taken in the light-hearted manner intended. The conference seemed well-attended and the organisation was top-notch. Jeremy, Jenny, Emma, Lorna and everyone else involved did a… continue reading.

Hooks in Action Helpers

Following on from the discussion on Zend Framework Action Helpers, let's talk about hooks within them. Hooks are a feature of action helpers that allow you to automatically run code at certain points in the dispatch cycle. Specially, there are two hook functions available for action helpers: preDispatch(): runs before the action function is called postDispatch(): runs after the action function has completed These allow you to ensure that some functionality is always run for… continue reading.

Using Action Helpers in Zend Framework

When you have some functionality that needs to be shared across multiple controllers, one method is to use action helpers. Action helpers are very powerful and contain hooks to automatically run when you need them too, but you can ignore all that if you don't need it. The first thing you need to do is decide where to put them. The latest default project structure document recommends using a sub folder from your controllers directory.… continue reading.

Where is php ?

A question came up on the phpwomen channel today about how to find the path to php executable for use in cron scripts. The answer that came back very quickly to use which or whereis. It turns out that the server in question is a shared host with a control panel for access to cron and ftp to upload your files. A test proved that shell_exec() wasn't going to work too. After discussing it for… continue reading.

PHPNW08 schedule posted

From one conference to another one. On the 22nd November 2008, the PHPNW08 conference in Manchester takes place and I'm speaking! My talk is entitled "First steps with Zend Framework" and it will cover an introduction to ZF and then walk through building an MVC application using the Zend Framework. There are lots of interesting talks scheduled so far. They look aimed at a wide and I want to see every one. If you are… continue reading.

ZendCon 08

I'm now back from ZendCon which was the most intense conference I've ever been too. I arrived late Saturday evening and after dropping off the stuff at my hotel, I walked the mile or so to the conference hotel to meet up with some #phpc people. I didn't stay in the Hyatt as it was too expensive for me. The walk took a little longer than I expected as I kept walking the wrong way,… continue reading.