Nowadays, few enterprise websites run without PHP, the dynamic scripting language that serves as the "P" in the LAMP stack. Coding PHP applications is relatively easy thanks to the abundance of high-quality PHP frameworks available. Here's a high-level overview of several of these open source frameworks, noting their scalability, maturity, licenses, and commercial support. While they may differ in many ways, they have one thing in common: they cost nothing to try and to use.
PHP frameworks not only make web development fast and easy but also standardize and streamline the whole development process. They are much more than just snippets of code or libraries you can reuse. They guide you through the whole development process, from laying out file structures to building data connectors and performing unit tests. All of these popular frameworks are object-oriented and follow the Model-View-Controller (MVC) design philosophy.
Zend Framework is probably the top corporate choice among these PHP tools because it is backed by Zend Technologies, which offers paid support and consulting, along with Zend Framework certification programs for professionals. These factors, combined with the software's enterprise-favorable new BSD license, make organizations feel comfortable using Zend – though the framework is also popular among non-corporate users. It has a strong community that produces a large number of plugins and extensions. One of ZF's tag-lines is that it "provides functionality for the 80% of the application code that is common across many applications." One proof of that is that Zend classes are frequently used outside of the framework and even in other frameworks.
Getting started with ZF takes no time. Once you have installed it and its binaries are in your shell executable search path, use the command zf create project example to create a new test site. Naturally, the core framework files remain in one place and can be reused by an unlimited number of applications – so it's a good idea to ensure that these files cannot be altered by a compromised application.
zf create project example
ZF is often considered to have a steep learning curve, so you should be prepared to learn a lot of new things even if you are already well-acquainted with object-oriented PHP programming and the MVC concept. Furthermore, some critics argue that ZF is overengineered, and heavier and slower than other frameworks. Despite the criticisms it remains the most widely adopted framework for enterprise-level projects, and is used for projects of any size and complexity. You can see ZF in full action in Magento, the popular ecommerce solution, which is based on Zend Framework.
If speed is one of your primary concerns, the Yii framework prides itself on its performance, and offers tests to prove it's the fastest among all popular PHP frameworks. Yii is not backed by a large company as Zend is, but its helpful community contributes actively to its large collection of extensions. The most notable Yii extension is Ext4Yii, which provides server-side ExtJS functionality.
Speed in Yii is not just about rendering code. You can get started with the framework in no time and build a fully functional site, with sample static pages, a contact page, and even an admin area, with the simple shell command ./yiic webapp example. The files structure is similar to the one for ZF (and most other PHP frameworks); the directories for MVC are inside application_path/protected/ and the configuration file is application_path/protected/config/main.php.
./yiic webapp example
Yii also includes a useful web-based code generator called Gii that can automatically generate MVC models and even create Create, Read, Update, and Delete (CRUD) functionality. All you need for it is a working database connection and an existing database table. Yii supports SQLite (used by default), MySQL, PostgreSQL, Microsoft SQL Server, and Oracle.
Yii has the same license as Zend Framework. However, Yii has no official commercial support yet, which makes it less favorable for large organizations. Even though it is well documented and there are books about it, the project offers no official certification plan to distinguish Yii professionals. Finally, Yii lacks as many native extensions as other frameworks, but even the non-native ones are easy to use.
Taking everything into account, we'd say that while Yii is suitable for use in almost any project, it is best for projects that require high performance and scalability.
CakePHP is designed for rapid web development. Its slogan could be, "If you like Ruby on Rails you'll love CakePHP." CakePHP attempts to take all the good principles from RoR and apply them in a PHP framework.
CakePHP also has command-line scripts, which can generate the basic application structure and build the MVC data. It uses a so-called scaffolding technique, which is similar to the CRUD generator in Yii but is less mature and customizable.
CakePHP has a substantial community contributing to the core framework and its extensions collection, called Bakery. Its MIT license is favorable for community-based projects where knowledge and code can be more easily shared. However, CakePHP has been criticized by ROR users and other PHP frameworks' users for being confusing, resource-demanding, and slow. It might be suitable for smaller projects where speed and scalability are not of major concern, but it's generally considered inadequate for big business and larger projects.
CodeIgniter is another PHP framework with a BSD-like license. It emphasizes simplicity, documentation, and compatibility; its small installation package contains only two folders plus one for its user guide. Code goes in the application folder, while the framework core files are kept in system.
While frameworks such as Yii are best used with shell server access, CodeIgniter is designed to be easy to use even with the more restrictive access provided on shared hosting servers; you need only FTP access to your server. While it may not have all the advantages of the other frameworks it has the necessary classes for anything from URL routing to caching, and it certainly does what it claims: provide a simple and elegant toolkit for full-featured web applications.
While these four frameworks are the most widely used for PHP development, many others are available. Some other popular, general-purpose frameworks are Prado, Symfony, Kohana, and Solar.
The total number of maintained PHP frameworks is probably above 100, and that doesn't count the many private frameworks used only inside organizations. A popular joke says that every developer dreams of having his own framework.
No matter which framework you work with, remember that they are only tools; how well the PHP applications you build work depends on how you implement it. Thus a well-designed web application in CakePHP with good caching logic may be faster than a similar one dashed off quickly in Yii. This precept contributes to the endless discussions about which framework is faster and better – a discussion that has no single right answer.
Allowed tags: <a> link, <b> bold, <i> italics