A web application framework is a bunch of source code organized into a certain architecture that can be used for rapid development of web applications.
Frameworks conform to the Don’t Repeat Yourself (DRY) principle, which means that they have all the pieces of logic coded only once in one place. This rule forbids duplication of code, especially copypasting. This facilitates maintenance of code and prevents nasty errors. Generally, frameworks promote code reusability and other good programming practices wherever they can, which is great for programmers who do not have enough knowledge or discipline to care for quality of code by themselves.
Framework versus Library:
The main difference between a library and a framework is that:
- libraries are called from your code
- frameworks call your code
In other words, a framework is a skeleton that serves as a platform on which you build your modules. Whereas a library instead provides attachable modules on top of a platform made by yourself.
What features and capabilities should we look for when choosing a framework?
- Simple to use
- Facilitates application performance
- Ensures security
- Separates HTML from PHP
- AJAX support
- No restrictions in terms of the PHP constructs that can be used and not having to use custom syntaxes
- An API provided to deal with the framework (object-oriented versus functional)
- Encourages code quality
- Enforces best practices
- Ability to configure
- Supports internationalization
- Availability of comprehensive documentation
- Active community around the framework
- Availability of commercial support
- Friendly license that encourage business use
- No vendor locking
- Availability with web hosting solutions
Here is a list of a few leading PHP frameworks that you might consider evaluating for your project.
Open source with MIT license.
CakePHP is a rapid development framework for PHP. It has the provision to use MVC within the convention over configuration paradigm, and eliminates the need for configuration requirements. CakePHP also promises less code.
CakePHP defines a comprehensive set of best practices covering security, authentication, and session handling.
The framework provides an object-oriented API for the programmers to work with.
Open source with custom license.
CodeIgniter is a PHP framework with a very small footprint. Because of the small footprint, good performance can also be expected. CodeIgniter also promises wide support for shared hosting accounts. One of the most interesting features of CodeIgniter is that it does not require a custom templating language.
Thorough documentation is available.
Zend Framework is based on simplicity, object-oriented best practices and a rigorously tested agile code base. Zend Framework is focused on building more secure, reliable, and modern Web 2.0 applications.
Zend Framework has comprehensive MVC support, with clear separation between the presentation, business logic, and data access layers. It also has support for AJAX for the presentation layer. It also has support for web services and data syndication formats. You can use those as an alternative to your database driven data model.
In addition to the MVC support, Zend Framework comes with a comprehensive object-oriented PHP 5 class library. It has paid proper attention to best practices like design patterns, unit testing, and loose coupling in the design of the framework and the API.
Open source with custom license.
Symfony is a comprehensive framework based on PHP5. It provides an architecture, components, and tools, for developers to build complex web applications. It makes use of the best practices of web development by integrating some third-party libraries.
Symfony is one of the most popular PHP5 frameworks around. Therefore, there is a large community behind it. This makes it very easy to find help, documentation, and plugins.
Yii was founded by a developer of Prado and it continues many of its conventions. Yii is very fast (leading in most benchmarks) and extensible, modular, and strictly object oriented. It has a rich set of features and decent documentation. It uses no special configuration or templating language, so you don’t have to learn anything apart from object-oriented PHP to use it. Also, unlike many other frameworks, it follows pure MVC architecture with data being sent directly from Model to View.