In this four-part article series, you'll learn about the model-view-controller (MVC) design architecture, why its use is a best practice when building web applications, and how using the Zend framework for PHP lets you make the most of this architecture. This article is excerpted from chapter 25 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).
While PHP has long been perfectly suited for development the MVC way, no widespread solutions emerged until the wild success of Ruby on Rails ( http://www.rubyonrails.org/) seemingly turned the spotlight away from the language long known as the reigning king of Web development. Thankfully, PHP enthusiasts are practical folks and borrowed heavily from the compelling features espoused by not only Rails but also many other MVC frameworks. The following list highlights four of the more prominent PHP-specific solutions.
Note You'll also find that each of the frameworks introduced in this section has significantly more to offer than an MVC implementation. For instance, each facilitates Ajax integration, input filtering, and database interaction. You're encouraged to carefully investigate the unique features of each in order to determine which best fits the needs of your particular application.
The CakePHP Framework
Of the four solutions described in this section, CakePHP ( http://cakephp.org/) most closely corresponds to Rails, and indeed its developers readily mention the project was originally inspired by the breakout framework. Created by Michal Tatarynowicz in 2005, the project has since attracted the interest of hundreds of active developers and has even led to the founding of the nonprofit Cake Software Foundation (http://www.cakefoundation.org/) and CakeForge (http://cakeforge.org/), a community repository for hosting Cake-driven projects, plug-ins, and applications.
The CakeForge initiative is showing considerable success, with 100 hosted projects and more than 2,100 registered users at the time of publication. Interesting projects include BakeSale, a Cake-driven shopping cart and catalog system, Cheesecake Photoblog, a customizable photoblog, and CakeAMFPHP, a Cake- and Flash-driven bulletin board.
Note Unlike the three solutions that follow, Cake is capable of running on both PHP 4 and 5, meaning users faced with hosting providers who've yet to upgrade to version 5 still have an opportunity to take advantage of a powerful PHP framework.
The Solar Framework
Solar ( http://solarphp.com/), an acronym for simple object library and application repository for PHP 5, offers an extraordinary number of classes for facilitating rapid application development. Founded and led by Paul M. Jones, who is also responsible for several other major PHP projects, including the Savant Template System (http://phpsavant.com/), DB_Table (http://pear.php.net/DB_Table), Text_Wiki (http://pear.php.net/Text_Wiki), and Yawp (http://phpyawp.com/), Solar benefits from both the experience gained and lessons learned from Jones's active involvement in building other popular development solutions. Text-to-XHTML conversion, role management through a variety of mechanisms (file-based, LDAP, SQL), multiple authorization mechanisms (.ini files, htpasswd, IMAP, LDAP, and others), and interesting features such as social bookmarking components are just a few of the capabilities Solar has to offer.
The symfony Framework
The symfony framework ( http://www.symfony-project.com/) is the brainchild of Franois Zaninotto, founder of the French Web development firm Sensio (http://www.sensio.com/). What's unique about symfony is it's built atop several other mature open source solutions, including the database abstraction layer Creole (http://creole.phpdb.org/trac/), the Mojavi MVC layer (http://www.mojavi.org/), and the Propel (http://propel.phpdb.org/trac/) object-relational mapping layer. By eliminating the additional development time otherwise incurred in creating these components, symfony's developers have been able to focus on creating features that greatly speed up application development time. Users of symfony can take advantage of automated forms validation, pagination, shopping cart management, and Ajax interaction using Prototype (http://prototype.conio.net/).
Note To learn more about the symfony framework, consult the fantastic documentation found on the project Web site (http://www.symfony-project.com/). Also, check out The Definitive Guide to symfony by project founder Fabien Potencier and project documentation leader Franois Zaninotto (Apress, 2007).
All three of the aforementioned frameworks are extremely capable and prominent solutions used by countless developers around the globe. There is however another solution that is showing considerable promise, and accordingly is given special attention in this chapter.
Please check back next week for the continuation of this article.