Pragmatism in the real world

The Redirector action helper

Following on from the discussion on the FlashMessenger action helper, I thought I'd also cover another supplied helper: Redirector. Redirector does what it says on the tin and redirects the user to another page. I mostly use this when coming back from filling a form in, so that the user is then redirected to another page. In admin systems, this is usually a list page. On front end websites, this is usually a thank you… continue reading.

Zend Framework's Flash Messenger action helper

I've talked about Zend Framework's action helpers before, but haven't covered any of the action helpers that are supplied with Zend Framework. FlashMessenger is a helper that allows you to store messages between requests. The most common use I have for it is for a "saved" message after doing an edit of an item that then redirects back to a list. This is how it's used: Storing a message Storing to the FlashMessenger is easy.… continue reading.

Matthew Weier O'Phinney: Using Action Helpers To Implement Re-Usable Widgets

Matthew Weier O'Phinney has just published an article on how to create reusable widgets with action helpers. I had a twitter/IRC exchange yesterday with Andries Seutens and Nick Belhomme regarding applications that include widgets within their layout. During the exchange, I told Andriess not to use the action() view helper, and both Andriess and Nick then asked how to implement widgets if they shouldn't use that helper. While I ended up having an IRC exchange… continue reading.

New Zend_Auth tutorial

After too many months of neglect, I have completely rewritten my Zend_Auth tutorial so that it is compatible with Zend Framework 1.10! As an experiment, I have written it directly in HTML, rather than PDF as before and cover the login form along with the login controller code required to authenticate a user using a database table. For good measure, I've included logging out and a view helper to show how to access the logged… continue reading.

Akrabat_Db_Schema_Manager: table prefix support

I've updated Akrabat_Db_Schema_Manager so that it now supports table prefixes. It uses the application.ini key of resources.db.table_prefix as I couldn't think of a better one :) and then uses that for the schema_version table's name and also makes it available in your change objects. For example, if application.ini contains resources.db.table_prefix = "myapp", then the manager will create the table myapp_schema_version to store the current version of the schema. In your change classes, you can then… continue reading.

Community Review Team for Zend Framework

On the ZF mailing lists, there's been a discussion on creating a community team with a follow-up by Matthew. I was going to write up a little about it as I'm one of the volunteers on the team. However, Pádraic beat me to it and I don't think I could have written it any better, so go and read his write-up instead! The CR Team at the moment is: Rob Allen (Akrabat) Pádraic Brady (PadraicB)… continue reading.

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.

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.

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.

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.