PHP Frameworks

December 19th, 2011

There has been an explosion in the number of PHP frameworks over the past several years for use with PHP. This coincides with the explosion of the use of PHP in web development. PHP is easy to learn and was designed as a language specifically for producing web pages. This means that choosing PHP as your implementation language allows you to build a dynamically-generated web site quickly and easily.

However, coding in PHP, or most any language, can get repetitive when the same task is coded time after time. This results in lost productivity and the possibility of introducing coding errors. This is why frameworks have been built.

A framework streamlines the development of web applications by providing a basic structure. They promote rapid application development (RAD), saving time, money and providing the ability to get a product (maybe MVP for a lean startup) to market faster. A framework also helps build more stable applications as framework code, once it is developed, thoroughly tested and subsequently used, doesn’t require the same amount of testing each time it is used as a newly built application. Frameworks can enable you to get increased productivity and coding reliability from junior developers, which can result in reduced development costs and allow you to spend more time creating the actual web application rather than writing the same code to do common functions time after time.

The general concept used by a framework is the use of a Model View Controller (MVC) architecture. The basis of the MVC architecture is to isolate the business logic from the User Interface (UI) and the input logic while providing a loose coupling between the elements. In MVC, Model refers to data, View is the presentation layer and the Controller receives user input and initiates a response. The use of an MVC architecture allows you to work on individual components of an application while leaving the other elements untouched.

As I mentioned, there are many different frameworks, some of the most widely used being Zend, Symfony, CakePHP, CodeIgnitor and Yii. You can even create your own. However, you should always examine your project to decide if you should even use a framework. Will the framework save the development team time and effort? How will the app perform? Will the framework improve application stability? If so, a framework should be considered.

In a future post I’ll discuss the advantages and disadvantages of using PHP frameworks in greater detail.