Sunday, November 27, 2011

Fastest PHP Framework

A web application framework is designed to support the development of dynamic websites, web applications and web services. It aims to alleviate the overhead associated with common activities performed in development such as database access, templating frameworks and session management, and it often promotes code reuse.

I have been coding Web Applications using PHP for a while and I find frameworks as very useful. It has an MVC (Model-View-Controller) approach, enforces good coding standards, has helpers and components which makes my coding life easier and saves me a lot of time and effort with its features. I and my officemates have been using CakePHP as our PHP framework for awhile and we think that its performance is becoming slow. We're thinking of trying out CodeIgniter, another famous PHP framework, but it makes me wonder, if it really is the fastest and most feature friendly framework we are looking for?

I did some research and I found DooPHP has quite an interesting portfolio.
Fig 1: DooPHP benchmark as of Febuary 25, 2011
DooPHP is claiming it might be the fastest MVC based PHP framework in the world. Beside that, it comes with features essential to today's Web 2.0 application development. It focuses on 7 main cores: MVC, REST, URI routing, ORM, Template engine, ease of use and performance. It even has a very loosely coupled design where developers can modify and add new functionailies to the framework easily.

Quite interesting right? What's not to like in this framework? Well for me, since it is still relatively new (started in 2009), I don't think it has a wide support base unlike its predecessors. Also, it feels like a hybrid framework. Why? One of the reasons why we use frameworks is because of its support for MVC.
function signup_action() {
/* Set the pages title */
$this->data['pagetitle'] = 'Signup';
// Load the User Model
// Get a new User Model Instance
$user = new User;
// Try and find a User with the specified username
$result = Doo::db()->find($user, array('limit' => 1));
In this example, we can see that it is accessing its data through the controller. That is not a good practice for "FAT MODELS, THIN CONTROLLERS" approach. It destroys the ideal MVC. Sure, it is faster but maintainability and reusability wise, it could be a pain in the future. For small scale projects, this could work since maintainability won't be much of an issue. Also, I get the feeling that it is like I am using classic PHP because I have to do/declare everything by myself as shown below:
class User extends DooModel {
    public $id;
    public $username;
    public $password;
    public $group;

    public $_table = 'user';
    public $_primarykey = 'id';
    public $_fields = array('id', 'username', 'password', 'group');

    function __construct(){
        parent::$className =;__CLASS__;

The closer you are to classic PHP, the faster your codes will be. Rasmus Lerdorf, the Godfather of PHP himself, believes that frameworks aren’t that great because they perform much slower than simple PHP. If you have to use a PHP framework, Rasmus likes Code Igniter the best, as it is "least like a framework"[2008]. We all have different needs, different wants and it all boils down to which framework will suit it. DooPHP is still young. It might be the fastest because it is almost similar to classic PHP, but it might be problematic in terms of scalability. Maybe after a few more years and this will be a framework to watch out for!

For now, I think I'll stick to CakePHP and will try its new stable version 2.0. :)

Other helpful resources:
DooPhp model guide
Learn DooPhp
10 Principles of the PHP Masters
CakePHP Best Practices: Fat Models and Skinny Controllers

No comments:

Post a Comment