Symfony 1.0 Released

Symfony is an open-source PHP web framework, much in the same vein as CakePHP (which I use), and it hit 1.0 yesterday. I hopped in to take a closer look at things by poring over the documentation and comparing it to what I know about CakePHP.

Very similar yet very different

Symfony and CakePHP take very similar paths when it comes to how they approach things. It's the typical MVC approach with controllers broken up into actions. There's routes (for handling custom URLs), views, helpers, model behaviours and a bunch of other very similar items.

However, they're also quite different in a number of areas and some features might be good or bad depending on how you look at things.


Much of the configuration is handled via YAML files. Many of the features within the application can be defined and controlled via the YAML files. There's even a handy YAML reader object allowing you to build configuration files for your own application.

Data Passing

In CakePHP, data is passed between the client and server through a data variable. Knowing this has served me well and I've been able to conveniently pass data back and forth (like ?data[Profile][name]=Jonathan). Symfony takes a traditional approach and actually uses regular variable names (like ?name=Jonathan).

Output Escaping

All variables used within a template can automatically be escaped for improper data. This is actually a really nice feature and one I wish CakePHP had.


Models are handled quite a bit different in Symfony than they are in CakePHP. Ultimately, all records are handled as objects (they're arrays in CakePHP). The schema is defined in a YAML file and the database tables can be built automatically using a command line syntax.

As a result of this, there are a number of base methods that are automatically created. These objects can be extended with any custom methods. In addition to the base and extended objects, there are also peer objects which are used as a querying interface to retrieve a list of objects from a particular table.

Where I think things get really complicated, is in handling selection criteria. Here's an example:

$c = new Criteria();
$c->add(AuthorPeer::FIRST_NAME, "Karl");
$c->add(AuthorPeer::LAST_NAME, "Marx", Criteria::NOT_EQUAL);

$authors = AuthorPeer::doSelect($c);

As you can see, the peer object is used to define object constants and to select the content from the database with the criteria object. Pretty much all of this is a result of using Propel as the ORM wrapper.

Internationalization (i18n)

One bonus is that i18n features are built into Symfony right from the get-go and when defining your schema, you can even define where the i18n data will be stored.

PHP5 only

By sticking to PHP5 only, they've been able to make heavy use of the OOP features. If you need PHP4 compatibility then CakePHP is definitely the one to stick with.

Saving time?

Ultimately, when I look to a framework, I ask if it's going to save me time. Most of the technical choices I've made have been asking myself that question. While there's a lot of power in Symfony, I feel like much of the database handling is too complex for my needs. Handling criteria needs to be much simpler. The configuration of the application is also much more complex (but at the same time, more powerful) with frequent command line scripts. The default install recommends using Pear for installing the application itself along with any plug-ins that might be needed.

On the flip side, there's a few features from Symfony like output escaping that would be nice to have and other handy objects like response handling are already really well thought out. The built-in i18n is also a huge bonus.

Symfony isn't for the faint of heart but if you're willing to invest the time and have a flexible hosting environment with Pear and PHP5 then Symfony may just be the framework for you.

Check it out over at

Published February 20, 2007
Categorized as PHP
Short URL:


12 Comments · RSS feed
NiKo said on February 20, 2007

Symfony is ORM independant, you can use the sfDoctrine plugin instead of Propel :

J Wynia said on February 21, 2007

I think that the biggest appeal symfony has wasn't mentioned. The utilities to auto-generate CRUD screens, administration screens, etc. makes rapid development of those repetitive structures easy. That can be really useful even just for prototyping an idea.

I know it was the demo screencast of them building an admin interface REALLY quickly that convinced me to give it a look.

Nate K said on February 21, 2007

RE: J Wynia
If you are referring to 'scaffolding' then it is available in CakePHP as well (and RoR). I agree, this is a nice feature of a framework.

I have checked out Symfony as well (read through the documentation), and I still prefer Cake for the simplicity. Cake is dead simple - yet is very flexible and powerful. I have spent the last 2 weeks learning and diving into the API (version 2), and I love where it is headed. You have the ability for custom configurations in cake as well, its just not stored in an array of different config files.

Personally, I like the way that database results are stored in an array. This works great when you are working with multiple models that may have some of the same field types (or names). It also helps you keep things organized (at least for me).

PHP5 is one of the really nice things, but I program Cake with 5 as well (in my models/views) and it all works just fine. Cake started out in 4, and I think its doing a good job of managing both.

As for escaping output, I would agree - I wish Cake had this at the core. It would be very easy to add as a custom function or method - much like rails has h() for escaping their output. Maybe we will see this soon, who knows.

I would agree with you in that they are very similar in regards to goals and setup of the framework. For me, I am sticking with Cake due to simplicity - and I don't feel like spending 2 more weeks learning another framework when I have what I need now. hehe.

Aaron Bassett said on February 21, 2007

I've given cakePHP a quick look more than once but have never really given it a proper chance even though I know I should.

Symfony is a new one to me, and to be honest from your review I don't think it would suits my needs either.

What's your take on Code Igniter?
It was the first MVC framework I stumbled across for PHP and the fact I have been quite happy with it is probably why I haven't looked too hard at cakePHP.

Does cake have any major advantages over code igniter that I should consider?

Jonathan Snook said on February 21, 2007

@NiKo: I took a peek at sfDoctrine and it didn't really seem any better. In fact, I'd use Propel instead. Ultimately, I still prefer the CakePHP approach which works well for 90% of the cases out there (I still don't love it's many/many relationship handling but that's another story).

@J Wynia: I didn't mention the CRUD screens because CakePHP has that as well (it's called Baking). Which is really nice, for sure. I used it to build a timetracker app super quickly (like, 20 mins).

@Nate K: admittedly, one of the things I haven't really looked into is extending the view class like I've done with the Model and Controller classes. On one hand, I feel like the documentation doesn't really tell you how, leading me to believe it'd be more complicated to do; but on the flip side, so much is easy to do already, it's probably a pretty trivial thing to do. Extending the view is the next thing I really want to do in CakePHP.

Dragos Badea said on February 22, 2007

This is really great !
I am using CakePHP currently, but the screencasts on their website made me want to take a closer look to this Symfony.

I heard before about it, but I didn't knew it was so powerful. Indeed, more configuration, but the results are also more acurate.

And the admin generator looks really cool, this is a thing that is missing to CakePHP. I am kinda` lazy when it comes to admin panel and I think this would be a great improvement to Cake.

Nathan Garza said on February 22, 2007

I've also been using cakephp for quite a while, and I love it! I've even found a couple of ways to get around the many/many issues.

I'ld have to agree with you about the purpose of a frame work. I've heard a ton of good stuff about symfony, but just can't justify the time to learn a new frame work. Cake has dramatically increased our production speed already.

Jonathan Snook said on February 22, 2007

@Aaron: to specifically address your question on Code Igniter, I feel that CakePHP has many conveniences over CI, mostly in regards to database access and relationship handling. On the flip side, there are a number of classes that come with CI out of the box that don't come with CakePHP (but would be easy enough to add in).

Code Igniter, in my opinion, is easier to pick up, especially for those who've done their own PHP development for some time and really acts as a handy way of mapping URL's to controller/actions.

CakePHP, on the other hand, really has more conveniences in place but has a higher learning curve and doesn't come with handy components like email or xml-rpc, etc. They're really easy to drop in, though, so if you find a library out there that does what you want, it's easy to add.

Ryan Behrman said on February 23, 2007

I was at PHP UK Conference 2007 today and there was talk by one developer of Qcodo He tried out 7 frameworks indepth, and settled on Qcodo. He says he's never looked back since. I'm wondering if anyone else has tried it out in comparison to symfony and CakePHP?

Ivan said on March 09, 2007

Hi Jonathan,
look at CI (

oreonix said on June 30, 2007

I have tested 3 different frameworks, 2 php 1 ruby.

By far I think codeigniter is the easiest to get up and running. The documentation and ease of use made me take CI over cakephp. I will probably give RoR another go when I have more time. I needed to get something up fast though.

dont_like_publicity. said on February 16, 2011

I take Codeigniter over Cakephp and Zend. Codeigniter easy to read and program, i has large variety of libraries, and then new 2.0 version is the best thing i ever used the changes they made in code lowered my server CPU usage by 25%.
thank you codeigniter you guys are the best.

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.

Want to learn about scaling CSS for large projects?

I'm available for full and half-day workshops on scalable CSS architecture. I can provide on-site training for your team. Interested?
Get in touch.