Zend Framework

For a couple of years now, I have been learning and using the Zend Framework for building web based and database driven applications. I know many sites exist using legacy PHP code, but is it worth upgrading to a framework?

From an SEO’s perspective, it can prove to be a nightmare converting because of the way frameworks handle URIs can mean that the page has appeared to vanish or move location. The reason behind this change is because the framework is often based on an MVC layout, or “model-view-controller”, which means that the URLs need to specify the correct resource in the MVC layout.

Legacy PHP:

http://mydomain.com/file.php[?paramKey=paramVal...]

Zend Framework:

http://mydomain.com/[module]/controller/action/[paramKey/paramValue....]

Fortunately there is a solution that can be implemented which is to make the server send an HTTP code 301 – Moved Permanently, HTTP code 404 – Not Found, or HTTP code 410 – Gone. There are two levels that this can be performed at, either handled by apache directly requiring a brief change to the config files for each URI, or using Zend’s error handler. If you do use Zend’s inbuilt error handler, then additional functionality to parse the url correctly can be used and to prevent problems associated with hard-coded urls. To achieve the basic HTTP301 redirect, code such as this could be used in the controller:

$this->_redirect(
$this->view->url(array('module'        => 'mymodel',
'controller'    => 'mycontroller',
'action'        => 'myview',
'paramname'     => 'paramvalue')),
array('code' => 301));

A similar procedure, and as is sometimes recognised as better practice, is to utilise the Zend Plugin Adapters to create scripts that will always be called. This is particularly useful when authentication of users for certain pages.

From a security standpoint, the framework opens up a whole load of different functions to the developer. These can include preventing site hacks using SQL injection, form input validation, file upload validation and more. Also filters enable quick and easy validation of user inputs ranging from email addresses to barcode formats, so no need to hand-code regular expressions any more.

When developing, it can be so much faster and much more easy to understand what is going on than legacy PHP because of the core setup of Zend. Namespaceing of class names actually match up to directory locations within the application making it easier to locate where your classes are being called from. Database connections are setup automatically in the background so you don’t have to spend time ensuring you have connected in each file. Other Zend library functions allow quick and easy functionality that you can extend as required.

Overall, Zend Framework can provide heightened security and robustness for your application which in itself is reason enough. Also development times can be reduced as many processes in setting up an application are automated. Also, the framework is always improving so you can get updates and new functionality as they are released.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>