Design Patterns, Frameworks, Open-source, PHP, Software Architecture

Implementing your own Front Controller in Zend Framework

There’s no doubt that the additional complexity of implementing the default Front Controller in ZF results in a number of benefits. The most important ones are flexibility and extensibility. The Front Controller implementation takes into consideration the future growth of your application and its design reduces the level of effort required to extend it. A good example of this is the plugin architecture.

But, what if after evaluating the requirements of your system, you determine that there’s not sufficient complexity to implement the default Front Controller? What if you don’t need all that flexibility, a URL mapper, a ViewRendered plugin or an ActionStack helper. Maybe all you need is just a couple of controllers, and that’s it. It’s clear that the standard Front Controller does provide more options and meets every possible use case requirement, but at the cost of complexity and a lot of classes.

So, what to do? Do you choose a different tool for the job, or replace the default Front Controller with your own implementation? How hard can it be? Is it really that difficult to replace the most important component of the Zend Framework and maintain backwards compatibility?

You are about to find out.

In this series of posts, I’ll try to cover a few things I’ve learned about implementing my own Front Controller in Zend Framework. Most of the ideas and code are based on my previous posts:

Will simplicity finally meet power?

3 thoughts on “Implementing your own Front Controller in Zend Framework

  1. I think it leans towards the “easy” side, of course depending on how complex functionality you need… tho mostly you prob. can use the builtin functionality and mix and match for your needs.

    I get a feeling this series will again showcase how flexible ZF is =)

  2. Hi Jani.

    Indeed, ZF is very flexible and allows you to implement your own front controller, router, dispatcher, etc. That’s the beauty of the framework. The Zend_Controller component is very powerful, and it’s not my intention to replace it, but to offer an alternative that decreases the number of decisions a developer needs to make.

    ZF is a component-based framework and the components you use are based on your system requirements. My goal is to develop a front controller that is rigid instead of flexible, backwards compatible with ZF applications, focuses on speed, requires 0 configuration and favors convention over configuration. This alternate component may also help lower the barrier to entry for new developers.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s