Pragmatism in the real world

Using your own View object with Zend_Application

Let's say that you want to use your own view object within your Zend Framework application. Creating the view object is easy enough in library/App/View.php: class App_View extends Zend_View { // custom methods here } along with adding the App_ namespace to the the autoloader in application.ini: autoloadernamespaces[] = "App_" All we need to now is get Zend_Application to bootstrap with our new view class. There are two ways of doing this: within Bootstrap.php or… continue reading.

A review of PHP Benelux 2011

A couple of weeks ago, the 2011 PHP Benelux conference was held near Antwerp. This was the first time that I've been to this conference and I was very impressed by it. I presented two sessions that seemed to go down well which was nice. I travelled to Belgium with Ryan Mauger on Thursday and we had a poor journey that took around 12 hours to get there. Our first flight (10:45) was cancelled, and… continue reading.

Zend Framework 2 in Action

Possibly the most frequently asked questions about my book Zend Framework in Action is whether it is going to be updated. I'm delighted to be able to announce that Ryan Mauger (aka @Bittarman) and myself have agreed with Manning to write a new book on Zend Framework 2.0. to be called Zend Framework 2 in Action! It's very early days, so we have planned the Table of Contents, but have very little manuscript. The current… continue reading.

Translations of my Zend Framework Tutorial for ZF 1.10 & 1.11

Recently, a couple of people have very generously donated their time to translate my Zend Framework Tutorial into their native language to help their fellow countrymen. Firstly, Mario Santagiuliana has provided an Italian translation: Introduzione allo Zend Framework. Secondly, Radosław Benkel translated into Polish and I'm hosting the PDF here: Pierwsze kroki z Zend Framework.pdf. Thank you both!

Remove index.php from your URL

One thing you may have noticed with Zend Framework projects that use the baseUrl() view helper to reference CSS and other static files is that it doesn't work if the URL contains contains index.php. Let's explain, by using code from the tutorial. In the layout.phtml file, we link to a CSS file like this: <?php echo $this->headLink()->prependStylesheet($this->baseUrl().'/css/site.css'); ?> This code uses a baseUrl() view helper that looks like this <?php class Zend_View_Helper_BaseUrl { function baseUrl()… continue reading.

PHPUK 11 Conference in London

PHPUK, the conference organised by the PHP London usergroup is being held on Friday 25th February 2011. If you haven't bought your ticket yet, then you should! I'll be there talking about optimising a Zend Framework application, which should be interesting. I'm going to be looking at what's slow in the ZF code itself and have been profiling using xhprof which is the first time I've used it. It's quite good, once you have it… continue reading.

Enrise: Using MemCacheQ as a Message Queue

Tim de Pater of Enrise has written a new article on how to integrate MemCacheQ with Zend Framework application using Zend_Queue_Adapter_Memcacheq component: For www.nd.nl (a Dutch newspaper) we wanted a simple and free queue mechanism that integrates with Zend Framework for handling a number of jobs. We found MemcacheQ. The article then goes through how to run the memcacheq daemon and then shows the PHP code to add a job to the queue and then… 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.

2010 in pictures

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.

Handling exceptions in a Front Controller plugin

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.