PHP Frameworks, which to choose in 2013? A comparison. - developed.be

To be honest, I’m a bit fed up with Drupal lately. We’re stuck with an ever-growing fat Drupal6 site, and the monster doesn’t get easier to maintain. The question isn’t if we will upgrade, but to what we will upgrade. The logical upgrade to Drupal7 will be enormous because our website has over 150.000 lines of custom php-code (not mentioning css, js, themes). So moving to Drupal 7 or creating something entirely new based on a framework… I don’t dare to say how much difference in time it will make, but I do know that the new thing must be a giant step forward to what we have now.

Why moving from Drupal to a Framework?

As much as I love Drupal, the thing is… a lot of modules do kind of what I want, but they don’t do exactly what I want. Customizing a contributed module sometimes takes me as long as I would write it myself. Especially when there’s little info in the README-file or when there are hardly any comments in the code. To give you an exampe: it’s faster to lookup the url for the admin-page in the menu-hook, than to find it in the documentation or in the navigation.

Plus, what irritates me the most. When you have +75 modules, +100.000 nodes and +10 currently logged in users, the thing gets slow.. slooowww! Even with advanced caching tools such as Memcached,  view-cache or Varnish, the thing still goes slow, even on a dedicated server. No wonder: every hook is checked for each and every request.

So I’m looking for something faster and more OO-like. I have a C#-background and the way classes are mimicked in php (including inheritance, namespaces) is simply terrible. I’d dare to say Drupal goodbye, as long as Drupal 8 isn’t released an is more decent.

My comparison of PHP Frameworks

Pfhew, long introduction, but here’s my research on PHP-Frameworks. Briefly, a framework provides a set of functions and classes to help developers write code faster and more structured. Most of them implement certain design patters, of which MVC is by far the most popular. The aim of MVC is to seperate the database-talking-code (Model) from application-specific code (Controller) from html (View). It also features a URL-mapping system to set “clean url”-rules and to separate the code-files from the actual urls (eg: /bootstrap.php shouldn’t be accessible through a browser).

Some devs use the bootstrap of a CMS as a framework-starter (like my RSS-boostrap), but it should actually be the other way around: a CMS should be build on a framework. Drupal8 will (maybe) rely on parts of Symfony2, but that won’t be out till 2014.

Django

I start off with a framework that isn’t PHP.

  • Django is a kind of MVC framework aimed for webdevelopment, based on Python (not PHP!).
  • Working with Django requires Python-knowledge. Python is a strong reliable fully object oriented language.
  • Installation/execution is through command line.
  • Django was developed by World Online (a Kansas newspaper) and is now open source.
  • Installation on a dev-server is pretty easy but the actual deployment requires a study (it isn’t just copying files).
  • Django has a CMS called Django-CMS. It’s pretty lightweight and provides basic functionality for creating and editing. But, the installation requires some configuration and Django-knowledge.
  • Django is a rather fast framework.
  • Django has a default “admin system” you could use as a backend. It can create/edit/delete objects and save them in the database.

I was eager to start with Django, but I don’t have any Python knowledge and the whole deploy process seems rather complex. For a complex website like ours, a total new language doesn’t seem the best option to me.

Kohana

  • CodeIgnitor-fork.
  • Each website needs a different Kohana “installation”. However it is just a server setup check. Not difficult or special.
  • Kohana works with the MVC-concept incl. mapping.Configuration is mainly in application/bootstrap.php and modules/…/database.php
  • Kohana gets criticized for its poor documentation. “Look it up in a code” appears to be the way to find out.
  • Lightweight, should be fast.

Kohana appeals to me. It all seems nice and clean, but reading negative reviews about dev-time and poor documentation makes me unsure.

Phalcon

  • A new framework, created in C to work togheter with PHP. The big difference here is that the framework isn’t built on PHP, but on C. This makes Phalcon the fastest framework out there [systemsarchitect.net].
  • However, very few projects have been realised in Phalcon (here’s a list of rather poor live examples [github.com])
  • I somehow didn’t manage to get Phalcon installed (and couldn’t find any Google help).

I think the support and documentation currently lacks because this framework is still new and doesn’t have a big community (yet). It’s also unclear how long the current version will be supported. Also, debugging will eventually require C-knowledge.

Symfony2

  • Bigger than Kohana in size, documentation and community.
  • They don’t claim to be MVC, there’s not really a Model but there is a View and a Controller.
  • It’s important to use Symfony v2 (not v1), because v2 is written from scratch to fully support erm MVC.
  • HTTP-reverse-proxy-cache, Varnish functionallity, various cachable blocks on one page. This is a huge plus.
  • Various benchmarks say Symfony2 is slower for small websites because of the weight of the framework. A lot of code must be executed for each request. (similar to Drupal)
  • Drupal8 will include parts of Symfony2 [davetech.com], so it might add up your Drupal-knowlegde in the future.

Hmm, Symfony eyy. However, the fact that it isn’t lightweight scares me here. It isn’t the intention to have a site as slow as our current. Also, the “quick tour” didn’t convince me.

Laravel

At this time, I’m getting a bit lost in all these frameworks and still 5 to go. It annoys me that the PHP-community isn’t behind 2 frameworks with both different goals. Instead we get a dozen frameworks all doing not just that what we want.

They all promise you heaven, but. It’s more useful to look up reviews (like this blog) than the marketing you find on the actual site. The real valuable information comes from the users, not from the creators.

  • Laravel looks more like marketing than anything else. Some self-confidence is good, but Laravel is way over the top about itself. But Laravel got quite some good critics, so I thought it’s worth checking out.
  • Laravel needs Composer to be installed and Composer requires a change in sohosin.ini (that will be shared-hosting-fun!). It also requires PHP >5.3.7 and the mcrypt extension, which is a good thing, because PHP 5.3 is an improvement on the previous versions.

Apart from that, the installation is pretty simple:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
composer create-project laravel/laravel website-name --prefer-dist
cd website-name
composer install

Your webserver needs to point to the /public folder in your website-folder. I found a valid nginx config here [laravel.io]. Apart from that, you need to give the webserver permission to write to the folder /app/storage and its underlying folders.

  • Laravel also contains a command line interface called “artisan” as I quote “is driven by the powerful Symfony Console component.”

I must say the quickstart manual is pretty straightforward and logic.  So far, it’s the only framework that didn’t hold me back for some reason. The database model and the OO-model don’t have to be exactly the same and can be specified apart, which I think is a good thing for flexibility. So far, this is my choice.

Silex & Slim

Silex and Slim are so called “micro-frameworks“. In other words: lightweights, but with only few features. Because I search a framework for a big site, I skipped those. But they might fit for your website. Both ought to be very fast (for PHP).

Zend & CodeIgniter

There are 2 other famous frameworks around: Zenn Zend (from the creators of PHP) and CodeIgniter. I didn’t check them out because I found only few articles that were positive about Zend and CodeIgniter was sufficient 7 years ago but is becoming a dinosaur. [Update 09/01/2014: David in the comments mentions: “It’s the newer frameworks that are more likely to go the way of the dinosaurs.“, good argument. ]

CodeIgniter was forked into Kohana and FuelPHP.

Conclusion?

In the end it comes down to this: lightweight frameworks (Django, Phalcon) will be faster, but will require a bigger investment from the developer. Full sized frameworks (Symfony, Zend) will have more out of the box functionality, but will tend to be slower (certainly for small sites). 

Keep in mind that PHP is pretty broken by default [veekun.com]. Frameworks provide a way around to deliver professional code, but you keep working on an inefficient stack. That’s why both Phalcon and Django appeal to me. For this project, the Django learning curve would be too high, and there aren’t a lot of Python-jobs around here. If for some reason I have to move away from the project, I want my colleagues to be able to find a new dev and there are more PHP-devs than Python-devs around (in Belgium). I also have 150.000 custom lines of php-code, and I want to recycle at least some code. Python would probably double devtime.

I will give Lavarel a serious try. It seems to be well supported, not too light-weighted but not a monster either. More soon on this blog.

Second Opinions

Phalcon: Anthony Ferrara (contra), SystemArchitects (pro)

Codeignitor: Phil Sturgeon (contra) 

Update 09/01/2014

[[ UPDATE 09/01/2014: With the recent popularity of this posts, there is some criticism about missing frameworks and the lack of information about Zend and CodeIgnitor.  I must say that these are my personal notes from a midweek research for a certain project. I didn’t exclude certain frameworks on purpose. Especially Yii and CakePHP should have been included. ]]


Rss Comments

24 comments

  1. Give try for phalcon or drop php for django.
    Later or sooner your site became larger and larger. Then OO php will slow you down. I had similar kind of code based on zend. It was slow. That phalcon offer something new.

    #1 Delifisek
  2. Please check more about Zend Framework.. its not called Zenn. Its now rewritten as Zend Framework 2 and is widely popular.

    #2 Tibor
  3. Worth checking: silverstripe.org
    OOP framework and cms built on top. Clean code and designed to be extended.

    #3 Mixel
  4. This sums it pretty well.. I looked for a PHP Framework for years but I never found one that fitted my needs: simple, light, easy to custom, documented :(

    Well written!

    #4 Sylvain M.
  5. Python isn’t a difficult language to learn for a developer who has a good grasp of OO principles. Like you I also have a c# background.

    The place I work is upgrading a large website with lots of custom code and we chose Django as the new platform. About two months ago I had never written a line of python code and only dabbled with php. Already I’ve made significant progress on the project, including a good chunk of custom code.

    I started with the Django tutorial, and a vague notion of python syntax. After a couple of weeks, I’m pretty comfortable with both the language and the framework, and it’s easy to find answers on the internet if you get stuck on how to do something.

    I have no experience with Drupal, but my understanding is that Django is a framework whereas Drupal is a full-blown CMS. There are some good CMSs built on top of Django. Customization is a strong point. Subclassing data models or building up your own works the way it’s supposed to.

    The template system is great to work with. It reminds me of ASP.NET Razor.

    If you have a couple days to poke around the Django tutorial, give it a try. I think you’ll like it.

    #5 Bread
  6. Haven’t you tried Yii Framework?
    It’s a php framework that is simple, fast, well documented and if you know MVC pattern it has a small learning curve…
    I think it’s perfect for small and medium sized projects.

    #6 enrico
  7. I had been using Django and I am doing fine with it. Hopefully the new version will be as good as the old too.

    #7 Ayesha
  8. PRADO is an event based MVC PHP framework that works through templates. It’s a wonderful system. Yii is a similar framework.

    #8 Wizard
  9. Laravel is the best PHP framework hands down. Uses trusted symfony componenets, and uses the newest and most modern ways of doing things in PHP. I highly recommend it.

    Although there is many other things outside of PHP, like Django or Rails. If you are going to use PHP, I would ignore all the older frameworks.

    #9 Mark LeMont
  10. Hi,
    I using Zendfox Framwork, it’s good to for small & large applications. It is very easy to understand and to use.

    #10 Ashutosh Tiwari
  11. CodeIgniter was forked by some devs into Kohana and FuelPHP. Lavarel is also based on these.

    Err….. come again?! Since you wrote this in July 2013, I’m assuming you used Laravel 4 (it was released end of May 2013). That is not based on CI, infact it has a component decoupling model (dependencies managed by Composer) and uses a number of Symfony components underneath. :) Not to say I’m a fan of Symfony but I found Laravel to be pretty easy to get up & running, almost as easy as CodeIgniter & thats saying something.

    #11 Amit
  12. Thanks for the correction, Amit. It’s indeed Laravel 4.

    #12 Robin
  13. I love the Yii Framework. Good implementation of Active Record and MVC, and a nifty code generator. My knowledge has improved greatly just by looking at the core Yii code.

    #13 Michael Sullivan
  14. Your while article is a load of tripe. Your opinions about ZF and CI make you out to be some amateur.

    If you want to play with the big boys, you need to play with the big toys.

    #14 JIMBO
  15. These are my notes about choosing the right framework for the job I had to do. I don’t say that CodeIgnitor and Zend are not worth checking out, or that they wouldn’t suffice for certain projects. This is just a web log, meaning it is a dairy about what I found out that day about frameworks, it’s not a science report.

    #15 Robin
  16. Try Kohana – We got tired with Drupal and developed CMS on it:

    https://github.com/gleez/cms

    Have a look.

    #16 Sandeep
  17. Interesting that you’ve completely ignored Yii, one of the top 3 or 4 frameworks, written off Zend and Codeigniter, two of the most used and supported frameworks, as dinosaurs and then spent a lot of time looking at other frameworks that are immature and potentially might be volatile and/or short-lived.

    The risk is that if a developer takes that approach they will be lumbered with a framework whose development stalls, or simply does not grow in the way they hoped, leaving them with something that has issues and requires constant work to keep up with their requirements.

    The thing about dinosaurs is that they are extinct, and a quick look at the figures shows that while new frameworks come and go, frameworks like Zend, Yii, Codeigniter and indeed Symfony continue to grow and evolve precisely because they do what they do well and continue to adapt. It’s the newer frameworks that are more likely to go the way of the dinosaurs.

    #17 David
  18. Also the complete lack of CakePHP makes me question the validity of this, CakePHP is the most stable Framework that is out there – it has a solid developer community behind it and excellent documentation, I also believe that it is the best RAD framework out there, it knocks down 90% of the barriers that the others put in front of it and has its own legacy – it isn’t a fork or an extension of another framework as the majority of the ones you have described there!
    I also agree with the people above Yii definitely deserves a mention and is my second choice of Framework nowadays.

    #18 Dan Voyce
  19. Codeigniter becoming a dinosaur?? As far as I know the project is dead (tear rolling down). It has never been a huge framework, but just the opposite: very lightweight. I liked it a lot. I’ve made great things with it, but since it seems to be discontinued a lot of CI people is moving to fresher frameworks like Laravel, which by the way has nothing to do with CI, and in my opinion it’s a good alternative.

    Strange nobody didn’t even mention CakePHP, which same as Zend or Symfony, they actually are the dinosaurs.

    #19 Luis
  20. I think Yii framework is a very good option to start.

    #20 Aviel
  21. At the time of posting this there were 745 Zend Framework, 159 Laravel and 128 Yii jobs listed. You should be asking why so many companies prefer ZF2 for commercial development.
    http://www.indeed.com/jobs?q=zend+framework&l=

    #21 Atlantic8
  22. I think about idea that MVC framework structure+parts should be part of native PHP language 3.5 years.

    This month when i really far a way from PHP somebody send me link to PHALCON – almost like my idea. I think also python and ruby should have native framework that will run much faster.

    Today steps that PHP have to do to survive node.js/rails/python raise:

    1. Phalcon should be integrated to be part of PHP 5.6 soon as possible – this will awake PHP from loose to ruby.

    2. Also should be in 5.6 create functions instead today functions that will be consistent like in python- all this function should start with s_print, s_split_words() etc…

    3. Add asynchronous native engine to PHP as NODE.JS

    4. Take Facebook HipHop or like that engine and make it part of native PHP. Its big importance for ecommerce systems to compile code before deploy to production for prevent errors/warning/bugs in compile time and fix them before they will naybe discovered by users in run time. (It exist opinion of unit tests that prevent that – they not prevent this issues in views+ in agile project all time demands changes and write all time unit test that big part of him going to garbage make script programming slow vs C#/SCALA)

    #22 Yosef
  23. Laravel is a good choice.

    I have experience with Yii, CodeIgnigter and Laravel. Been coding with Laravel for approx 1.5 years now.

    Yii – Too restrictive
    CodeIgniter – Dead
    Laravel – Extremely flexible, takes advantage of composer, easy to use facades, dependency injection, dependency inversion, easy to create enterprise level applications, keeps code clean and structured. Great inversion of control container, easy to create unit tests and functional tests, and easy to learn with the help of Jeffrey Way – Head of development at tutsplus!

    #23 Ahmet
  24. The main trouble with large framework for speed is often due to autoloading.
    As soon as there are sooo many classes to load, it takes a while to load all of them.
    Then symfony & Zend provide tools & advices to make it faster. Some third party modules do great job like puting all most used classes into a single file , witch reduce by far the autoload time.
    Also, they provide solid caching systems.

    For my point of view, symfony makes the code easyer, and is much more dev friendly.
    Zend takes a bit more longer to be widely understud and mastered, for my point of view, i better understand the whole with Zend than with Symmfony.

    I builded the same app with symfony and ZF2 ( i dived into both of them for the first time with this app, having solid background with ZF1), it was a lot easier with symfony because it gives developper great tools and great magic (handling all the cache by itself, generating forms in an entire automatic way and a great console tool…).

    But i didn’t succeed at making symfony be fast, i don’t have a dedicated server, only shared hosting.
    With Zend, i can manage to be as fast as expected, hugely faster than with symfony. I allmost love the feeling to understand all is going on backstage with ZF, and overriding native things looks pretty easy. My choice is definitly ZF2, but i do love Symfony ease of use.

    Laravel is nowadays growing fastly, it provides quick development with concise and easy to read code, pretty great ORM (if still love doctrine, and don’t wan’t to leave it).

    For any small project, you cazn choose any php framework, only your personnal preference will lead you to decide witch to adopt.

    For larger applications, the two blobkbusters are Symfony and ZF2, today i surely would pick up one of these two.

    for my two cents :-)

    #24 Anton

Leave a comment