Pragmatism in the real world

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.

Speaking at TEK·X

I'm delighted to be able to announce that I'm speaking at TEK X in May, in Chicago. This is one of the big US PHP conferences and I feel privileged to be invited. I'll be concentrating on Zend Framework with a tutorial called "Building a Zend Framework application" and a talk on "Working with Zend_Form". After a couple of less technical talks recently, it'll be fun to dive into more technical content. Hopefully, I'll be… continue reading.

Pragmatic Version Control Using Git

I've recently been looking at different version control systems, specifically distributed ones like git, Bazaar and Mercurial. At IPC I was talking to Travis Swicegood about wanting to learn and he very kindly organised a copy of his book for me to review and learn from. I didn't know much about git at all before reading the book. I do now :) It turns out that git is fairly easy when you have a good… continue reading.