Home > Development, Web Applications > Picking a Framework

Picking a Framework

Over the past few years I have checked out many of the popular PHP frameworks out there. The three I did the most development with were CakePHP, CodeIgniter and Zend Framework. Each one has fills a very different set of needs, and I think most people do not understand that. People seem to take framework reviews very personally for some reason as if its a reflection of their ability.

Addressing Your Needs

To oversimplify things, it’s easy to map your role with some of the different frameworks. I choose these three, because they represent my point very well. I’m going to fudge the definitions a little bit here, and toss WordPress (or ‘insert your favorite CMS here’) into the mix as well. While the mapping may be an oversimplification, remember that the particular role’s core needs may match your needs for a project, even if you fit another role.

Designers & Writers – WordPress

If you are a designer or content writer, you will want something simple to use like WordPress. It’s pretty easy to skin, and there is a wide variety of plugins/themes available. Even these add-ons are easy to work with. Given the short time required to get started, this is the most common choice for new websites, at least from what I have seen. Even web development firms will choose this when it fits the bill. There is no shame in that.

Keep in mind though, the WordPress codebase may not be the most flexible, and that is usually when you start climbing the ladder to more advanced solutions.

Cons:

  • Lower code quality
  • Hard to modify functionality

Pros:

  • Huge community
  • Quick to launch sites
  • Simple interface
  • Great plugins and themes

Coders and Designers – CakePHP

If you want a framework gets you from zero to launch very quickly, then look no further than CakePHP. It’s an MVC based framework, like the others, and imposes very strict coding conventions. This means if you learn how to code the ‘CakePHP way’, then it will do a lot of the work for you. Sounds too good to be true? It is, sometimes. Once you begin to deviate from the way CakePHP does things, then it becomes very frustrating to work with. However, its primary target audience is people who want to get applications up and running very fast. If I remember correctly, it’s based on some of the concepts of Ruby on Rails.

One thing Cake does very well is creating “CRUD” applications. CRUD stands for CREATE, READ, UPDATE, DELETE. These are common operations for custom (but relatively simple) databases. The work I have done with this was actually a pleasure, though pretty slow.

Cons

  • Forced conventions
  • Slower codebase
  • Outdated codebase (PHP 4)
  • Deep inheritences

Pros:

  • Shorter learning curve
  • Rapid development tools
  • Automation via convention

PHP / Front-End Developers – CodeIgniter

I find that the more technical designers or coders will use an open ended framework like CodeIgniter. It’s a decent MVC framework with a few extra libraries to make your common tasks easier. CodeIgniter is based in PHP 4, which is a turn off to some. CodeIgniter does not try to do everything for you, instead it does give you a loose structure to work with and build upon.

If you like to do things yourself, but want an MVC stack and some basic libraries to work with, then CodeIgniter is great. There are also some spin-offs of CI that are worth checking out (notably Kohana, which is PHP 5).

Cons:

  • PHP 4
  • Libraries not flexible

Pros:

  • Great documentation
  • Large community backing
  • Fast & simple
  • Open ended architecture
  • Decent libraries included

Backend Developers – Zend Framework

Zend Framework is a monster. It is very daunting to beginners, and unfortunately because it has changed so much in the past 2 years, most of the blogs for it are inaccurate. Zend Framework is the most complicated of the set, and it takes quite a large effort to get comfortable with it. However, it offers such an enormous amount of flexibility that it has become my #1 choice for some time now. You will need to be very hands on.

The best thing about Zend is how the code works. You can more or less pick different components that you want and use them in other applications. There may be a few dependencies, but compared to other frameworks it is miles ahead. You can also easily drop in other libraries to work with your ZF application.

Zend is for creating serious web applications which may need a lot of external libraries or access points. It is overkill for most websites; it’s meant for enterprise level websites or applications. Zend’s documentation is also a little difficult to understand at first, as it’s more from an API perspective. However, it has gotten better in the past few months to show big picture examples.

Cons:

  • Steep learning curve
  • Slower codebase
  • Smaller community

Pros:

  • High quality code
  • Very flexible
  • Highly modular code

Summary

There will never be a single framework that will fit everybody’s needs. It’s best to analyze your goals, and then go from there. Jumping to the biggest framework is never a good idea; neither is being stuck with a codebase that isn’t flexible enough and requires you to re-code everything. Experiment with a few and see which one fits your needs the most. Take into account things like community support, documentation, style, code quality, and efficiency. Without communities working together to improve these tools, they become useless and outdated.

  1. February 10th, 2010 at 16:24 | #1

    Adrian,

    I like your non-bias analogy! At the end of the day, it always come down to pick the right tool for the right job. and also the expertise your team members have.

    Great post! any words on Symfony?

  2. Adrian
    February 10th, 2010 at 16:47 | #2

    Thanks again, Jim.

    I would put Symfony on the same level as ZF. They are both very different, but in the end they both try to solve the same problem.

  3. Trond
    February 13th, 2010 at 02:22 | #3

    Very nice with “non religious” views to different PHP frameworks and it all makes sense.
    I’ve just stared out on Zend Framework and YES it’s a monster. I kind of back to the same idiot feeling as when I started to learn basic PHP and had lots of ideas but didn’t know how to put it to action.
    And of course I do not need to use Zend Framework as long as coding is just a hobby for me. But the challenge is intriguing and if I stand the test it will give some advantages longer down the road.

  4. February 24th, 2010 at 03:13 | #4

    you must have included Kohana (as a CI alternative)

  5. August 16th, 2010 at 10:11 | #5

    As Jim Li says, you must include something about Symfony . I learned something from symfony docs about MVC and all . Its well written . I played with some examples too .
    But for some reasons I am sticking with #zf . Yes its interesting to learn . Once you learned it , its really awesome . But you familiar much with OOP’s and want to read the docs carefully … Very very carefully . Missing a line may spend hours :) .
    Also we do have new borns , for PHP 5.3 :) . Lithium from the cake :)

  6. Adrian
    August 16th, 2010 at 10:38 | #6

    Symfony is an excellent framework. I try to track its development over Twitter and other blogs. It’s definitely my next choice to ZF. This post wasn’t aimed so much at reviewing specific frameworks, but to give perspective on how to choose one for yourself.

    I still feel ZF is lacking on real use documentation. The API reference is great, but they are still catching up on the rest. Supposedly ZF2 is supposed to really help remedy the high learning curve so I’m eager to see what they come up with.

    I’m definitely up for reviewing some of the newer frameworks in a few months time when my workload isn’t so high. It’s interesting to see what the rest of the world is up to. :)

    Cheers

  1. No trackbacks yet.