Pragmatism in the real world

Custom Zend_Application Resources

Sooner or later, you want to leverage Zend_Application better by creating your own resource plugins. This lets you reuse your initialisation work in multiple application that much easier and keeps your Boostrap class that much shorter! In my case, I wanted to create a resource for CouchDb that checked that the database was created and if not, create it. Creating your own plugin is easy enough. The obvious place is library/App/Application/Resource and a typical resource… continue reading.

Zend Framework on a shared host

When you deploy a Zend Framework website to a shared host, you usually cannot change the DocumentRoot to point at the public/ folder of the website. As a result the URL to the website is now http://www.example.com/public/. This doesn't look very professional, so we'd like to remove it. The easiest way, given a ZF project created using Zend_Tool is this: Create /index.php < ?php define('RUNNING_FROM_ROOT', true); include 'public/index.php'; This uses the index.php already created by… continue reading.

Accessing your configuration data that's stored in application.ini

Zend_Application will read the data in your application.ini and make it available from your bootstrap's getOptions() method. It then sets the bootstrap as a parameter in the front controller. Note that the top level keys are all normalised to lowercase too. You can then retrieve the options in a number of ways. In the controller you can do this: public function someAction() { $bootstrap = $this->getInvokeArg('bootstrap'); $options = $bootstrap->getOptions(); } Outside of the controller you… continue reading.

Zend Framework URL Rewriting in IIS6

I've written before about URL rewriting with IIS7's URL Rewrite module. IIS6, which ships with Windows Server 2003 does not have this module though and guess which version my client's IT dept run? As usual, they wouldn't install ISAPI_Rewrite or one of the other solutions for me. In the past, I've simply written a new router that creates URLs with normal GET variables, but this is ugly and I wanted better. One thing IIS6 does… continue reading.

Tutorial Q&A PDF

Chris Kirk has kindly provided a Q&A PDF which summarises a number of problems that have been raised and answered in the comments on the tutorial page. If you are having problems, download it and see if it helps. Thanks Chris!

My tutorial is compatible with Zend Framework 1.9

I've just updated my tutorial to version 1.6.3 after checking that it is still compatible with version 1.9 of Zend Framework. The only changes I had to make were: ZF 1.9 comes with its own BaseUrl view helper, so there's no need to write our own. ZF 1.9.0's command line tool doesn't work on Windows. I've created patches on issues ZF-7464 and ZF-7465. I'm sure this will be sorted with 1.9.1 though. ZF 1.9 looks… continue reading.

Bootstrapping modules in ZF 1.8 and up

I've started to play with modules in a Zend Framework 1.8 application as the new autoloader means that all your model directories no long have to be on the include_path for autoloading to work. What I'm specifically interested in is being able to instantiate a model that is within a module from within another module. Setting it all up isn't that hard, but I couldn't find a concise description, so these are my notes on… continue reading.

Metadata from Zend_Db_Table_Abstract

This post is part of a series about my experiences building a PHP app for Windows Server 2008 and IIS 7 for the European WinPHP Challenge 2009 which is sponsored by iBuildings, Microsoft and Leaseweb. I finally found some more time to work on SuccesSQL and can now display table structure information: Zend_Db_Table provides all this information directly which is quite useful, however the intended use-case for Zend_Db_Table is that you extend Zend_Db_Table_Abstract for each… continue reading.

Zend Framework Tutorial for ZF 1.8

Zend Framework 1.8, has been released! To celebrate, I have completely revised and updated my Zend Framework tutorial to support the new Zend_Tool command line tool and Zend_Application for bootstrapping. Let me know what you think :)

Zend_Loader's autoloader deprecated in Zend Framework 1.8

Zend_Loader's autoloader has been deprecated in the upcoming Zend Framework version 1.8 and so you now get a notice if you use it: Notice: Zend_Loader::Zend_Loader::registerAutoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead in /www/zf-tutorial/library/Zend/Loader.php on line 207 Notice: Zend_Loader::Zend_Loader::autoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead in /www/zf-tutorial/library/Zend/Loader.php on line 186 Notice: Zend_Loader::Zend_Loader::autoload is deprecated as of 1.8.0 and will be… continue reading.