Jan 25

cakephp.gifOver the last few weeks, I have been attempting to learn two major PHP frameworks: Symfony & CakePHP.

Originally, I had decided (in a bit of short-sighted wisdom) that Symfony was the obvious champion. I think I may have been wrong. I spent nearly a week tinkering with Symfony off and on. I came to a simple conclusion: I’m confused.

The Symfony framework is so huge and poorly supported that it confused the heck out of me. Their basic “sandbox” tutorial doesn’t work in any way close to what the documentation states. And the documentation, oh the documentation; what could be the best part of this huge framework fails because of one fatal flaw: no one updates it for the new each new revision that (sarcastically) seems to come out every other day.

After seeing my co-worker struggle with the installation process for days and my own copy just barely functional (with hardly a thing to show from it), I called it quits. At least until I read this (from The Symfony Blog):

“You know that we spent the last months writing a complete guide for
symfony that will be released in bookshops on January 29th. We also
mentioned the fact that the content of this book would become the
official symfony online documentation and be published in HTML on the
same date.”

So, it looks like I’ll put Symfony off until this new-fangled documentation goes live, then I’ll give it another swing.

In the mean time, I’ve been working with CakePHP and genuinely lovin’ it. After tinkering around with it for a while, here are my thoughts about the two frameworks:

Documentation
- CakePHP: Up to date, but not totally complete and somewhat difficult to search through. They also have an extremely helpful CakePHP Google Group that helped most problems I ran into quickly (almost instantaneously during normal business hours) and efficiently. You can’t beat live support that’s free.
- Symfony: Until the new release, not all that helpful because much of the content is dated. However, what is there is easily searchable and they have an active forum that seems to be full of knowleable (yet somewhat arrogant) people.

Installation
- CakePHP: Very easy to install. For the most part, just copy it into your web root and you are good to go (provided you have Apache and mod re-write previously enabled). Once it’s in there, all you really have to do is setup the DB connection and you can be off and running.

- Symfony: Ouch… this is my major sticking point here. I know people that would say, “If it’s not hard, it’s not worth doing”. I agree with that idea, but this is one tough cookie to crack. There are so many little tricks, files, variables, and directory permissions to set-up… it’s a wonder I even got to the point I did. Their basic tutorial, “my first project“, wouldn’t work by following the given instructions… no matter what I did. They also rely on Pear to deliver the goods, which is inherently fraught with little tricks to keep it all running smoothly.

Directory Structure
- CakePHP: It makes sense and it’s extremely logical for almost anyone. You don’t have to be the creator of the framework to understand what each directory is used for. The framework code is in a separate directory totally away from all of your own code. Props to these guys, it works well.

- Symfony: File and directory overload. We’re talking a huge amalgamation of directories buried within directories and files scattered all over the place. When I started really digging, it left me dazed. Truthfully, after spending countless hours working with Symfony, I still haven’t figured out what all the directories are there for (which could be because the framework kinda mixes it’s own libraries in with the programmer’s code).

I could go on for hours, but I think you get the picture. For the time being, I have revised my opinion on the matter of PHP web frameworks. In my somewhat humble opinion, I think CakePHP is the current champion. However, Symfony may present some good competition just as soon as their new release comes out on the January 27th, 2007. Only time will tell I suppose. Rest assured, I’ll be choosing one or the other.

UPDATE: My mind is made up – CakePHP wins! Please read this, and this.

41 Responses to “PHP Web Frameworks: CakePHP Versus Symfony”

  1. Anonymous Says:

    Man, I agree. Cake is the best. I don't think any framework is real easy to learn if you are used to standard PHP coding practices, but I have found it not too bad.
    Make sure to tell us what you decide.

  2. Dustin Weber Says:

    No decision yet, but I sure am liking what I’ve done with CakePHP. It truly seems to be a good solid framework and I can see it saving me some serious time in the future (once I get the hang of it)… regardless of if I use the scaffolding or not.
    - Dustin Weber

  3. Anonymous Says:

    Nothin' like bakin' a Cake!

  4. Anonymous Says:

    Symfony supports the lastest php5 technologies such as PDO. I was very disappointed when cakePHP claims they support both php4 and 5. Come on, php4 must die, and we have to move on…
    I would use cake only if they have a pure version for php5 or above.

  5. Anonymous Says:

    Exactly. The php5 fact lets me still undecided between the two.

  6. Anonymous Says:

    PHP4 has very limited support for OOP. That's why Zend developed Zend Engine 2 for PHP 5. A framework is designed with many OOP design patterns. If a framework supports PHP 4, I don't bother to try it.

  7. Dustin Weber Says:

    The PHP4 support was initially off-putting to me too, however, you need to consider a few things.
    You can work with Cake without having to worry about the PHP 4 stuff. Basically, you go to town using PHP 5 if you want. For the most part, it doesn’t make much of a difference, honestly.
    Secondly, OO PHP is an awesome thing that I use in every project I work on, but it’s cool factor doesn’t make it valuable in the real world. There are obvious advantages to organization, structure, et cetera, but you take a pretty large performance hit using serious object orientation in PHP, if you can even call PHP 5′s way of doing things “OO”. Let’s face it, most PHP developers develop their projects procedurally most of the time.
    So yo u can’t really blame them, can you? I give them props for being backwards compatible.
    Most importantly though, version 2+ of CakePHP will be the ‘pure’ version you are talking about. It will only support PHP 5+ and will be one heck of a powerful framework.
    It’s coming and it will dominate, IMHO.
    I honestly wanted Symfony to win the competition, but it’s total lack of structure, confusing API, and antiquated tutorials made me run the other way.
    - Dustin Weber

  8. Dustin Weber Says:

    I still think it’s sorta tongue-in-cheek to give PHP 5 credit for being object oriented. It’s got some functionality, but at it’s core, it’s just not OO, at least in my opinion.
    I also spent considerable time examining Zend. To me, it seems like just a new collection of libraries… like a steroid-enhanced version of Pear.
    - Dustin Weber

  9. Anonymous Says:

    I really hope cakePHP win the competition since it is so easy to use. However, as professionals we have to examine their performance, security, supports, etc. If you are using OO structure in your project, PHP 5.2 has BETTER performance than PHP 5.04. In turn, PHP5.04 has MUCH BETTER performance than PHP 4.4.1 in OO structure. Also PHP 5.1 or above supports PDO natively, which is highly recommended for its performance and security. Thus, at the time of writing, I would prefer Symfony over cake.
    When will CakePHP version 2.0 come out? I will definitely give it a try.

  10. Dustin Weber Says:

    I agree for the most part. I won’t get into the semantics of my disagreement, but I do agree that support of PHP 4 could ‘technically’ cause performance differences, but I truly believe it would only be in very distinct and specific cases.
    Plus, I tend to think this performance difference would end up being highly negligible for all but the most extreme (busy) sites.
    In the mean time, I’m not sure as to the road map for Cake 2.0. I suppose I need to find that out at some point.
    - Dustin Weber

  11. Anonymous Says:

    A year ago I had to make the same decision (i.e. chooosing the PHP framework). I choose symfony. I don't know why you say that documentation is poor. The single biggest selling point of

  12. Anonymous Says:

    The Cake google-group is awesome, but the IRC channel is really the best place to get help.

  13. Dustin Weber Says:

    Thanks, I’ll check that out.
    - Dustin Weber

  14. Anonymous Says:

    Heh, to say that PHP5 is OOP, (especially if you're saying that PHP4 *isn't*) is just about the biggest myth in the PHP world. No version of PHP, not even 6, is actually an OO language. The object support is simply a high-level “wrapper” around the existing PHP functionality.
    Some of it was reworked for version 5, i.e. adding support for interfaces, abstract classes, and the hooks necessary to integrate the SPL, but it still lacks basic OO constructs like multiple inheritance and polymorphism. But in terms of OO patterns, there's really not a whole lot you can do in PHP5 that you can't do in PHP4, which is why we've been able to emulate several of PHP5's OO constructs in PHP4 at the framework level.
    Also, the fact remains that over 90% of public servers are running some version of PHP4. If the core PHP team weren't so busy breaking things (ahem, 5.2.1) maybe we wouldn't be having this problem, but PHP4 is a fact of life for the forseeable future. Deal with it. If we didn't want our framework to be very popular or gain much traction, sure, we'd have targeted PHP5 only.
    @Dustin: hey man, thanks for the props, it's always good to hear about what we're doing well (and not so well). We've worked really hard to make the getting-up-and-running process as painless and bulletproof as possible.

  15. Anonymous Says:

    I came to the very same conclusion about Symfony. I really gave it a shot with over a month of time put in, but its dependence on other bloated third party pieces and completely complicated file structure meant that any programmer I gave a symfony site to would revolt! CakePHP, much more logical, though it is still its own world. Cake 1.2 looks great!

  16. Mark Says:

    I thought CakePHP looked interesting until I found no support for PDO. I don’t think there is an excuse for such a fundamental missing PHP 5.1x feature. For one of the main developers this shouldn’t take more than a couple of days to create. It makes me wonder what other dead ends I will find down the road if I use CakePHP. The Cake isn’t done until PDO is supported.

  17. Dustin Weber Says:

    @Mark

    I don’t know how far you got with CakePHP, but I bet you could forgive any lack of support there if you really sat down and learned the API. Each additional project I work on in Cake excites me even more. It has made my life easier, my code better, and frankly saves me a lot of hassle that I used to consistently deal with.

    It’s very flexible and you can easily make do without PDO. To tell you the truth, I would guess that Cake 1.2 (due out any time) will support it anyways. If not, a simple request might get the job done.. just like you stated.

    You won’t find many dead-ends with Cake though, I’ve found it very open and extensible on the rare occasions it’s actually needed.

    - Dustin Weber

  18. M. Ghorbani Says:

    I used to fly up websites using my home-made framework. But when I take CakePHP as a framework, I can say that it is the most EOF (Easy Object Oriented Framework , But yet powerful!) I ever met.

    I donate to these men whenever I can.

    - M. Ghorbani

  19. Mo Ziada Says:

    So , What do u think guys , do i have use CakePHP or Symfony , for my next Project, it is big one, shopping cart + Inventory Managment system
    i used home made framework for my co-worker , but i need to run this project away from this framework
    so please help me to choose ….
    Thank you
    mohamedm2000 at yahoo dot com

  20. Dustin Weber Says:

    @Mo Ziada

    CakePHP is the way to go in my opinion. I’ve worked on many projects since I wrote this article in Cake and I’m extremely pleased with it… and I think you will be too.

    - Dustin Weber

  21. Mo Ziada Says:

    -> Dustin
    Thnak you very much for your advice

    hey very small AJAX with cakePHP ( pretty cool )
    http://demo.grahambird.co.uk/tasks

  22. noel Says:

    I used symfony on a rather large community site. I got used to it eventually, but I agree with most peoples’ frustrations here. I’m about to start a new, smaller project with Cake, and the whole things feels easier to master, more intuitive, and easier to extend for my own needs.

    I am disappointed in the php4 style OO though. If I start writing public static this and private function that, am I going to break the framework? I can live without abstracts and interfaces. There’s no mention of exception handling either.

    Another concern is upgrading. Say you use cake in a project you want in your own svn. Well you can’t just svn co the cake project and then maintain your project with svn. So you’re probably using the stable tarball. If I dl the new tarball and overwrite my mods, I lose a lot of important work. Symfony is maintained in pear and is pretty much 100% separated from your project. I haven’t found any upgrade how to’s for Cake…

    IMHO, if you need i18n support and some of the other things that only symfony offers, then jump the gun. Otherwise, Cake seems the faster to deploy choice. It’s also more performant (again because symfony has more under the hood — not always a good thing).

  23. eric Says:

    I just tried to learn Symfony. The learning curve is indeed quite steep. The documentation is very confusing. Bits of information here and there. Is Symfony trying to imitate Java with all its complexity?

  24. amed Says:

    i certainly agree ! symfony seems to be a great idea but very complicated to use i spent hours trying to get it installed !! then i failed so i decided to give up and try cakephp !! went to the site downloaded it and in 2 mins i got it installed!!

    i dont know guys i would really go for cakephp because php is popular because its easy programming language! symfony is making php more difficult!!

    Good luck

  25. gaus Says:

    I explored the symfony framework extensively, reading (most) of the documentation, following the (few) tutorials and experimenting on my own. I have a beginner to lesser-intermediate understanding of PHP OO and MVC implementation. I have never built a real functioning web app. I must say, that though symfony seemed hard to grasp, huge and bewildering at first, I really had no problems following the tutorials or understanding the documentation. I got it up and running using the sandbox first, then installed it on my Mac using Pear, no problems; everything worked as it was supposed to. It seems a very powerful (albeit daunting at first) framework for building web apps. I just started fooling around with CakePHP, they seem very similar. The CakePHP website and docs, bakery, etc.. seem more ‘friendly’ than symfony however.

  26. xentek Says:

    Symfony is configuration hell, and relies on so many external libraries that its ability to innovate is stifled by this fact. CakePHP on the other hand is all their own code, and has a robust community behind it. The docs are incomplete, but at least they work. But between all the resources that are up on offer (google group, irc channel, the bakery, the manual, and the screen shots), you can find all the info you need. Not to mention the API docs, that will get you pretty far too.

    Zend is good too, and is coming along nicely (check out 1.5 PR). I use both Zend and Cake, and with Zend you get more flexibility over everything, including the directory structure. But of course that flexibility comes with its own responsibilities and details that cake just manages for you. Sometimes that’s good (new app) sometimes its a liability (upgrading exisiting app).

    It can be used as independent libraries (which is a nice feature), but when you start using the frontController, MVC, and other core libraries the difference between it and cake start to really fade. 1 important distinction to make about Zend is this: Its not a Rapid Application Development framework. RoR, Cake – those are RAD frameworks. But that doesn’t make Zend ‘not’ a framework. Its just a different kind of tool.

    Oh and one last thought… Cake’s support of PHP4 is a feature, not a bug. And is one of the few frameworks to support it. I use 5 when and where I can, but sometimes things just take longer to upgrade, especially in an Enterprise environment… Hell, even Media Temple just got PHP5 for their Dedicated server plans.

  27. Alden Says:

    All you guys have great comment about those framework. I hope to see symfony more in the future. I love those state of the art framework.

  28. Kris Wallsmith Says:

    There is a new, extensive tutorial on symfony 1.2 available here, http://www.symfony-project.org/jobeet/. I would encourage everyone to at least read the tutorial if not follow along.

    Comments on symfony are also welcome on Twitter.

  29. Renee Nguyen Says:

    I’ve been following along with Symfony’s Jobeet tutorial for about a week now. It does seem to have a steep learning curve. I have used Ruby on Rails and loved the simplicity but just wasn’t ready to switch from PHP to Ruby. With Symfony, honestly, I am confused. The tutorial is pretty clear IMO but some things take me a while to understand. Although some people will argue otherwise, I like the use of the Terminal/Command Line in Symfony.

    However, after reading this article and several comments, I am going to try CakePHP with the hope that it will be easier for me to learn.

  30. Lourenzo Says:

    Nice work comparing those frameworks and sharing this rich information to us.

    By the way, I’ve found a broken link, at the foot note on the previous post. It’s pointing to a 404 page, but it should point here, I think.

  31. Jeena Says:

    I’m a long age CakePHP developer. And I started using Synfony too.

    Symfony is far more complex than CakePHP. This can be read as a defect of Symfony (from the ones who are looking for semplicity) or a major flaw of CakePHP (from the ones who are asking a lot to the framework).
    I love CakePHP: it licterally saved my life.
    CakePHP lacks a lot of important features, which ae not immediately visible to every developer.
    No doubts Sympfony is much more hard to learn and use. No doubts CakePHP has a set of serious flaws that may limit it’s use.

    CakePHP: genial, simple, quite light, easy to learn. Can be limited, too much simple
    Symphony: much more hard to learn, a bit slower. But it’s the state of the art of frameworks. When you start thinking Cake lacks something, take a look to Symfony, it may have what you’re looking for.

    Symfony has Environments, custom sets of settings to manage test, developing and production setting. Cake has nothing like that: just a simple, poor set of configuration and bootstrap files. Symfony has a very advanced system of cascading configuration that allows every kind of granularity. It’s like having configuration with inheritance. Can it be useful? You judge.

    Cake’s ORM is really simple to learn and use and it fits most of the requirements. Most of applications don’t need anything better than Cake’s ORM. But it’s very limited too. Cake’s ORM is the biggest Cake’s limitation (that’s why CakePHP team is working on a new ORM engine for the next Cake’s realeses, take a look to the road map). Cake’s ORM manages arrays while Sympfony’s one (Propel or Doctrine) offers a serious and professional ORM. “Lazy loading” is unavailable on Cake and developers must make use of workarounds like $Model->recursive, Bind/UnbindModel and the Containable behavior. Symfony’s ORM, on the other hand, retrieves real objects, which expose real methods, with lazy loading. Workarounds like the callback methods BeforeFilter, BeforeSave and so on are just, ehm… workarounds. If only Models in CakePHP were real objects able to retrieve objects and not arrays, they would be completely useless. Doctrine and Proper allows Symfony’s developer to completely separate Business Logic to database. On Cake a Model cannot be a real business logic object, because it’s linked to a table, it executes queries and so on. This is simpler and can be very useful until you have to develop a very very advanced application. Then, Cake’s ORM flaws emerge. And then you will appreciate Symfony.

    My opinion is: learn and use CakePHP first. It’s a magic framework and working with it is really joy. There’s nothing better than CakePHP, until it stops fitting your requirements: no CodeIgniter can equal the Cake’s facilities. When you start being annoyed with Cake’s limitations, take a look to Symfony: you will be already prepared to concepts like conventions over configuration, standard directories structure, MVC, ORM and so on, and you will be able to appreciate the hardest parts of Symfony: they are there to overcome Cake’s flaws.

  32. Maxim Says:

    ILOGOS’s main focus is professional software engineering and the company’s expertise covers all major IT engineering areas for: IT-companies, Software outsourcing companies, IT-departments, IT-specialists. So, having learned your business, we mean and hope that our companies have common interests and common business opportunities.
    We are ready to propose offshore development for your company at hourly rates 10-15euro.
    Fulfilled projects – http://ilogos-ua.com/projects.shtml
    All our services – http://ilogos-ua.com/service.shtml

  33. dimis Says:

    Me also wanted to learn cakephp after my first framework CI, but I did not use it (cake).
    Now I am using yii I thing is good as cake (I let down CI).
    Symfony is complicated and mabe fits mor complicated projects.
    I am learning Symfony now. :)

  34. listen to free beats Says:

    My persistent civil libertarianism will cause an ulcer if I keep reading stories like this.

  35. Jpsy Says:

    Jeena’s remarks are the most fundamental and valuable comments in this chain. I strongly suggest to follow them. Cake is a great entry point for PHP MVC frameworks. But if you dive deeper you will find many limitations. Even the “workarounds” that Jeena mentioned are not complete. The beforeFind/beforeSave/afterSafe callbacks do not propagate through associated models for example, which makes them quite useless in many scenarios. Meanwhile Cake has also learned I18n, but the missing callback propagation makes any translation stop when it comes to associated tables, and so the I18n is hardly usable (talking of v1.3 of CakePHP).
    Never the less Cake is a very good point to start. It gives you fast results and is just fine for smaller projects. And I am very curious how it will develop on.

  36. Jogos Says:

    I am learning cakephp. I thisnk that the main problem is the lack of an IDE

  37. Mr. T Says:

    After a while you just need to read the source, looking for doc takes more time!
    Anyway both of this two frameworks sucks, they exist only because people are lazy and keep php alive.

  38. Lukasz Says:

    Man, Thanks a lot for this short compare. Now I know I should start from CakePHP. I’m using from year Zend Framework and it’s very good but everything in ZF takes too much time.

  39. Steve Says:

    This review is so old it should be taken off the web. A new review should be written that compares the 2 latest versions.

  40. srinivas Says:

    Which is the latest framework that is good? any ideas?

  41. Panjianom Adipratomo Says:

    Symfony is the best framework if you want to build a large website & database.
    Until now there’s no other PHP framework can beat it.
    CakePHP is only for small to medium size’s site :)

Leave a Reply