Fabulous PHP frameworks: Qcodo, Lithium, Seagull, and Yii

Alternative PHP frameworks offer such advantages as code generation, prebuilt modules, and application performance

The lesser-known Qcodo, Yii, Seagull, and Lithium PHP frameworks may not be as extensive as Zend Framework and Symfony or as approachable as CakePHP and CodeIgniter, but they have other virtues to recommend them. Qcodo's command-line tools -- used to jump-start an application -- perform actual code generation from the database model. Unlike applications built from the other frameworks, Qcodo applications do not rely on PHP introspection at runtime and, thus, enjoy a performance boost. Both Yii and Seagull are large-footprint PHP frameworks. Yii excels at building database-centric Web applications, while Seagull boasts an extensive collection of prebuilt application components. Finally, minimalist Web developers will be attracted to Lithium's lean lines and ultrasmall footprint. Like Symfony, Lithium relies on other PHP open source technologies that its engineers have harvested from around the Web.

Qcodo PHP framework requires at least PHP version 5.1.2. While most other frameworks use runtime reflection as the underlying mechanism for creating data-access classes, Qcodo uses code generation. It will read the database and not only create the classes for modeling your data, but also generate the presentation code (HTML and PHP) for performing the fundamental CRUD (create, read, update, delete) operations on your database. Qcodo builds actual source code, so it executes prior to runtime (among other things), gaining a performance benefit as a result. In addition, Qcodo keeps the data-access code separate from any customization code you might generate. Should you modify your data model and regenerate the data access classes, your customization code isn't obliterated.

Qcodo also provides an event-driven view system called Qforms. As its name implies, Qforms' primary use is for building data-entry pages. Its real magic is that it lets you employ HTML form elements as though they were JavaScript widgets. For example, you define a button and its text property with code like:

$this->btnButton = new QButton($this);
$this->btnButton->Text = 'Button Label';

You can attach event handlers to the widgets. These handlers are PHP methods that are called on the server when the event is fired (for example, the user clicks the button), thanks to the clever use of behind-the-scenes JavaScript that Qcodo employs invisibly.

Qcodo's documentation is spotty, but what's to be had is quite good. It's a fine PHP framework that's worth a look.

A minimalist system, Lithium is a PHP MVC (model view controller) framework that requires PHP 5.3 or later. You can get a whiff of the philosophy of Lithium by visiting the website, which is as Spartan as a four-walled cinderblock house. The Lithium project was launched by developers from the
CakePHP project. It provides the command-line tool li3, which can quickly create skeleton files for models, views, and controllers.

Lithium supports the MongoDB database server. MongoDB describes itself as a cross between an RDBMS and a key/value pair storage system, and it has the unique feature that you don't have to create a table before storing data into the database. (MongoDB's analog to a table is a collection.) MongoDB will create the persistent storage system the first time you access it. Lithium also supports "standard" relational databases like MySQL, PostgreSQL, and SQLite, as well as SQL Server through an official plug-in.

Lithium does not generate JavaScript code, but it supports integrating JavaScript into the framework on two fronts. First, Lithium uses view helpers to produce markup with embedded data that JavaScript can read. Second, Lithium enables conversion of any HTTP request/response to JSON (JavaScript Object Notation), which enables easy parsing in JavaScript. In addition, Lithium exposes the raw request object to Lithium controllers, which promotes custom response handling by AJAX.

Lithium appears to be still under construction (at the time of this writing, it was at version 0.9.9), and its roughness shows in the documentation. For example, the documentation under the console command reads: "More documentation will be placed here as the built-in commands become more usable and finalized." Nevertheless, there is much promise here, and we hope Lithium progresses at full speed.

Though Web development is its primary focus, the
Seagull PHP framework claims support for building command-line and GUI applications as well. Seagull requires PHP 4.3 or later, and it employs an HTML templating engine called Flexy.

Seagull's installation is quick, and an installation wizard ensures that the installation was done correctly. The framework consists of base classes that implement the MVC architecture, assisted by modules and libraries that extend the capabilities of the base. Seagull's module-generating command-line tool automates the process of creating new modules. Seagull also has a well-developed administration system. A user cannot reference a module until the module has been registered by an administrator (the module is invisible until officially registered).

The Seagull website leads to numerous prebuilt modules that you can deploy either as examples of proper framework use or as code to include in your own application. These modules include a CMS, a FAQ page for your website, and even a newsletter module that handles the process of mass-mailing an HTML-formatted newsletter to your site's registered users.

Finally, Seagull's documentation is extensive, including installation instructions, API reference, and a wiki boasting a long list of how-to articles. Diagrams of the framework's structure and execution flow are particularly helpful for novice users.

Yii framework requires PHP 5.1.0 or later. Like Qcodo, Yii generates actual PHP source code to get your application off the ground, via a pair of tools: Yiic and Gii.

Yiic is a command-line tool that creates the basic files and directory structure for a Web application. Execute Yiic in your application's root directory, and it will build all the code necessary for four fundamental pages in your application: the home page, an about page, a contact page, and a login page. The pages are fully functioning, ready for customizing to your specific application.

Gii is a graphical tool that runs in your browser, and it builds CRUD code for database access. Create a database and database table, add the connection string to your application's /config/main.php file, and point your browser to your application's index.php file with the string "?r=gii" appended. This will launch Gii, which provides you with a wizard to generate the model classes for the database table. Once that's done, you can use Gii's CRUD Generator to build the database access code for that table. (You can, of course, repeat the process for as many tables as are in your database.) The CRUD Generator even has a preview button for viewing the results prior to code generation.

Yii provides JavaScript integration via Zii, an extension library that uses Yii widgets as wrappers for JUI (jQuery UI) widgets. The Yii documentation consists of an online book, "The Definitive Guide to Yii," as well as a tutorial that proceeds step by step through the process of building a Yii-based blog application. While Yii claims that it can be used to build command-line and GUI-based applications (other than Web applications), its strength lies in the ease with which you can construct database management code. That feature makes it a solid choice if you're building a database-centric Web application.

Read the reviews of other PHP frameworks:

Also on InfoWorld:

This article, "Fabulous PHP frameworks: Qcodo, Lithium, Seagull, and Yii," was originally published at InfoWorld.com. Stay up on the news in software development and PHP at InfoWorld.com. For the latest business technology news, follow InfoWorld.com on Twitter.


Copyright © 2011 IDG Communications, Inc.

InfoWorld Technology of the Year Awards 2023. Now open for entries!