Pragmatism in the real world

Akrabat_Db_Schema_Manager: Zend Framework database migrations

So, it turns out that I had a need for database migrations within a Zend Framework project that's using Zend_Db_Adapter. Those of you with long memories may remember that I created a proposal along these lines back in 2006. Nearly four years later, I read it again and implemented the core section. One of the comments, by Wil, asked why it's worth bothering with a DDL to create tables, columns, indexes etc. as sooner or… continue reading.

Photos of Seagulls

Today was a good day in photography for me as for the first time in absolutely ages, I took some time out to take photos for the sake of taking the picture. My son was at a birthday party and I had about an hour free, so I went down by the river Severn in Worcester. Worcester has a cathedral and I was lucky enough to have some lowish sun shining on it: I don't… 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.

Zend Framework, IIS and 500 errors

One of the dangers of frameworks in general is that you forget that they do lots of handy things for you. Consider Zend Framework's default error controller: public function errorAction() { $errors = $this->_getParam('error_handler'); switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error — controller or action not found $this->getResponse()->setHttpResponseCode(404); $this->view->message = 'Page not found'; break; default: // application error $this->getResponse()->setHttpResponseCode(500); $this->view->message = 'Application error'; break; } // Log exception, if logger… continue reading.

Mobile web monopoly

There's a recent post by Peter-Paul Koch called The iPhone obsession about how Mobile Safari is being treated by web developers as the only web browser to develop for. PPK likens this to how we all used to only develop for IE6. Unfortunately, the article has lots of hyperbole and iPhone hate which significantly detracts from the actual message. The fundamental point is that Mobile Safari is not the only web browser available on phones… continue reading.

Zend Framework Tutorial for ZF 1.10

Zend Framework 1.10, was released a week or so ago. As a result, I have updated my Zend Framework tutorial so that it is completely current. The main change I made was to remove the _init methods in the Bootstrap as they are no longer needed. I also take advantage of the new features of the zf tool to enable layouts and create forms. It's a shame that it gets the class name of the… 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.

Determining if a ZF view helper exists

This is another one of those posts that exists as a record for me so I can find it again if i need it! If you need to know whether a view helper exists before you call it, one way is to write a simple view helper to tell you: class App_View_Helper_HelperExists extends Zend_View_Helper_Abstract { function helperExists($name) { return (bool)$this->view->getPluginLoader('helper')->load($name, false); } } You can then use it in a view scripts like this: <… continue reading.

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.