Rails-inspired PHP frameworks

A roundup of six different PHP frameworks inspired by Ruby on Rails

There are various articles online examining many PHP frameworks, providing short reviews or comparative charts, but I could not find yet an article examining the so called “Rails-inspired frameworks” anywhere on the web, so I decided to write my own…

IMPORTANT UPDATE: I do no longer recommend the CakePHP framework anymore due to the unprofessionalism of some member of its development team. My site is now powered by Ruby on Rails and I totally lost interest in PHP and any PHP framework. If you are looking for a decent web framework, try Ruby on Rails (for Ruby), Django (for Python) or Catalyst (for Perl).
I'm talking about those PHP frameworks who give at least part of their success to Ruby on Rails2, but don't call them clones or ports as some of their creators may get offended.

Since Rails shocked the world with an easy-to-use, powerful and semi-sentient web development framework, web development is not the same anymore: everything must be done efficiently, quickly and you have to produce a Web 2.0 compliant public beta after X days/weeks/months or your work is simply not useful to anybody. Try doing that with the traditional PHP spaghetti code: you can't, it's too much, it will be too tangled up and in the end you'll lose your mind trying to find that small insignificant bug which makes your web application completely useless.

Yes, you could use Rails, but maybe you don't know or don't want to learn Ruby, your host doesn't support it, your boss loves PHP etc. etc. If you're in this situation or you simply would like to know what's going on at the PHP front of the Rails Clone War, you should keep reading this article.

I'd like to introduce – briefly – six Rails-inspired PHP frameworks and compare them with each other, to point out their features, their pros and cons.

Disclaimer: I'm a CakePHP3 fan, this site has been built with CakePHP and I even wrote something4 about it in the past. This makes me inevitably partial and more familiar with this particular framework, but I'll try my very best to provide a relatively objective analysis. Obviously frameworks which are not based on the MVC architechture and that weren't inspired by Ruby on Rails have not been included, so forget things like PRADO, Qcodo, eZComponents, or even Mojavi: it's not that they are “bad”, they've just been left out because they are not pertinent to this article

CakePHP

Website: www.cakephp.org
PHP version: PHP4 and PHP5
License: MIT5
Download size (.tar.gz): 184KB
Supported Databases: MySQL, PostgreSQL, SQlite, MS SQL + any other supported by ADOdb or PEAR::DB database abstraction layers
Beginner's Tutorial: Blog Tutorial

Official Description:
“Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility.”

PROs:

  • Lightweight, not bloated, containing only essential code
  • Runs both on PHP4 and PHP5
  • No configuration needed – except for a stupidly short database configuration file and a few constants which can be modified. You can literally start baking in less than five minutes
  • Extended table association support, allowing the creation of complex database architechtures
  • Extremely logical and functional directory structure: better than Rails, if you ask me.
  • Enhanced AJAX support through the AJAX and Javascript view helpers
  • useful “bake” command line script to generate parts of the code automatically
  • Very active community and plenty of satellite sites
  • Suitable for every kind of website, from the small personal site to the advanced e-business application.

CONs:

  • No “official” internationalization support for now, but it will be included in the next milestone.
  • It does not take fully advantage of PHP5 features
  • Official documentation still needs some some improvement, although now it seems pretty complete and exhaustive.

Comments:
CakePHP is my personal favorite: easy to learn, easy to use,multi-purpose and not bloated. Cake's philosophy is not to include unnecessary code in the framework unless it's absolutely necessary for the framework itself, as a result, 3rd-party libraries are not included in the official releases, but may be seamlessly integrated with the framework if developers need them.
Cake's success is partly determined – at least initially – by the fact that it can run fine with no limitations on PHP4, while other similar frameworks don't. Although this may still be one of its most obvious strengths, it must be said that Cake seems to go in the right direction, taking only the best from Rails, without forcing developers into complex and pointless adaptations, and evolving into a great framework created in PHP, for PHP.

Symfony

Website: www.synfony.project.com
PHP version: PHP5
License: Symfony6
Download size (.tgz): 1255KB
Supported Databases: MySQL, PostgreSQL, SQLite, Oracle, MS SQL + any other supported by Creole database abstraction layer
Beginner's Tutorial: My first project

Official Description:
“Based on the best practices of web development, thoroughly tried on several active websites, symfony aims to speed up the creation and maintenance of web applications, and to replace the repetitive coding tasks by power, control and pleasure. […]
Symfony is an object-oriented PHP5 framework based on the MVC model. Symfony allows for the separation of business rules, server logic and presentation views of a web application. It also contains numerous tools and classes aimed at shortening the development time of a complex web application."

PROs:

  • Fully featured framework, includes everything you might ever need (see CONs, below)
  • Full native internationalization support
  • Truly excellent documentation, tutorials, wiki, book, screencasts, API, real-world examples, etc. etc.
  • Code generators
  • Various “pre-built” modules/libraries for the most common tasks
  • It was not inspired only by Rails, but borrows concepts and practices from various other frameworks
  • Good community support

CONs:

  • Seems too big compared to the others, too many “extras” which may not be useful to all developers
  • PHP5 only
  • Confusing and disorganized directory structure
  • Uses too many configuration files, not suitable for simple projects
  • Steep learning curve

Comments:
Symfony is really an interesting framework: it's perhaps the most complete in terms for features and documentation. The only problem I have with it is that it just seems too complex and rather difficult to learn if compared to the others, which can do almost the same things (or will soon be able to) in a MUCH simpler way. A nice blend of MVC, pre-built components, command line generators and YAML/Propel configuration files, but perhaps a bit disorganized in its internal structure, unlike its wonderful documentation and support section.

PHP on Trax

Website: www.phpontrax.com
PHP version: PHP5
License: MIT
Download size (.tgz): 843KB
Supported Databases: Any database supported by PEAR::DB
Beginner's Tutorial: How to create a Trax application

Official Description:
“Php On Trax (formerly Php On Rails) is a web-application and persistance framework that is based on Ruby on Rails and includes everything needed to create database-backed web-applications according to the Model-View-Control pattern of separation.”

PROs:

  • Simple, logical, essential: a true RoR port to PHP5
  • Code generators, like Rails
  • Zero configuration (like Rails and Cake
  • Easy and logical directory structure (the same as Rails)
  • Supports table associations, but more in a way which is more similar to Ruby on Rails than Cake.

CONs:

  • Lack of documentation compared to the others
  • Trying to port Ruby on Rails to PHP, ignoring why RoR was not built in PHP in the first place7
  • No internationalization or other advanced functionalities
  • PHP5 only
  • Small community
  • DBO class based only on PEAR::DB

Comments:
In my opinion this project aims too much to be a Rails-clone to acquire a proper consensus. Trying to port something to another language is not good, especially in the case of Rails and Ruby. This framework looks somehow like an old version of CakePHP, which evolved slightly but always remained anchored to its beliefs of building a Rails port for PHP (even in the name!). Some may say that this is a lost battle since the beginning – or better, since before it started – but others found that PHP on Trax can be the easiest way to switch from Ruby on Rails to a PHP equivalent. Who is going to do that? Well, Ruby programmers forced to develop in PHP, maybe. Not too good, but not too bad either.

Code Igniter

Website: www.codeigniter.org
PHP version: PHP4 and PHP5
License: CodeIgniter8
Download size (.zip): 609KB
Supported Databases: MySQL, PostgreSQL, SQLite, MySQLi, MS SQL + ODBC
Beginner's Tutorial: Hello World! Introduction to Code Igniter [video]

Official Description:
“Code Igniter is an Open Source Web Application Framework that makes writing kick-ass PHP programs simple as apple pie. […] Designed to enable, not overwhelm, Code Igniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.
If you're a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you're tired of ponderously large and thoroughly undocumented frameworks that require rocket science to understand, Code Igniter might just be the right tool for you."

PROs:

  • Good and organized documentation
  • Zero configuration (like Rails and Cake)
  • Includes various classes and libraries for common tasks
  • Compatible with PHP4 and PHP5
  • Medium-sized community
  • Intuitive directory structure
  • Ships with the full user guide included in separate HTML files

CONs:

  • No full (“written”) tutorials except the videos!
  • Relatively new to the scene, but growing
  • Does not seem to support table associations.

Comments:
People on the Net seem to be rather enthusiastic about this framework: where there's a thread about the big ones (Cake and Symfony), there's always, someone who pops in suggesting to try out Code Igniter. I personally think this can be a true bless for small/medium sized projects, however, I'd opt for CakePHP or Symfony for a large scale application: something is missing, e.g., most notably, table associations.

Biscuit

Website: biscuitproject.tigris.org
PHP version: PHP4 and PHP5
License: MIT5
Download size (.zip): 240KB
Supported Databases: Any database supported by PEAR::DB
Beginner's Tutorial: Creating a simple application using the Biscuit MVC framework

Official Description:
“The mission of this project is to port Ruby on Rails to PHP5 (minus the Ruby part ;-)”

PROs:

  • Zero configuration, easy to deploy
  • Runs both on PHP4 and PHP5
  • Simple to learn

CONs:

  • Still under development and incomplete
  • Offers a limited subset of the features and functionalities offered by competitors: no internationalization, no table associations, no scaffolding…
  • “Documentation coming soon”
  • Almost non-existent community

Comments:
This project started as an attempt to create something simpler than CakePHP and more similar to Rails. I'm not sure whether the project is still active or not, since the last “release” on the former's developer site is dated August 2005. Still in early stage – or dead.

Pipeline

Website: livepipe.net/pipeline/
PHP version: PHP5
License: Pipeline9
Download size (.zip): 288KB
Supported Databases: SQLite
Beginner's Tutorial: none

PROs:

  • Simple directory structure
  • Suitable for small projects
  • Comes with various ready-made components
  • Supports table relationships

CONs:

  • PHP5-only
  • Too restrictive: only SQLite supported, kindly suggests developers to use its built-in features only
  • No documentation or tutorials, just the API
  • Not suitable for large projects
  • Almost non-existent community

Comments:
This project mainly borrowed the MVC architecture and some basic concepts from Rails, creating a simple PHP5 framework with personal/small websites in mind: it offers various built-in components which can be handy to most of us, supports only SQLite, and basically tells developers what to do. In my opinion it's not flexible enough to be compared to the others, and it's simply not suitable for anything other than small websites.

Conclusions

My favorite framework still remains CakePHP, it's simple and yet powerful, easy to learn and use, mature, well supported and continuously improving. Symfony – at the moment – seems to be the one with most features and the best documentation, and it is an excellent and well supported project. The only problem I have with it is the scary amount of configuration files necessary to create an application: CakePHP doesn't need any and can be used for (almost?) equally complex projects.
Although I didn't have a chance to try them out, PHP on Trax is certainly the most faithful port of Ruby on Rails to PHP, but it lacks some of the features CakePHP and Symfony offer. Code Igniter may not be as advanced as the others, but its community seems to grow and its simplicity may appeal more users in the future…

At any rate, developers should always choose the best framework for their needs: I tried to write a quick comparative analysis of these six Rails' “PHP children”, now it's your turn, try out some of them, if you choose wisely you won't be disappointed.

Notes

1 They are all distributed according to various Open Source licenses.

2 Ruby on Rails – Ruby framework for web development

3 CakePHP – Rapid [PHP] Development Framework

4 CakePHP – A ‘tasty' solution for PHP programming, originally published on zZine Magazine

5 Open Source MIT License.

6 Symfony License:


Copyright © 2004-2006 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

7 Read the comments by David Heinemeier Hansson on Ruby on Rails to Basecamp

8 CodeIgniter License Agreement

9 Pipeline is licensed under the same terms as the Symfony framework [Copyright © 2006 Picora Pipeworks LLC].