Over 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.
January 31st, 2007 at 11:01 pm
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.
February 1st, 2007 at 11:29 pm
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
February 5th, 2007 at 11:37 pm
Nothin' like bakin' a Cake!
March 1st, 2007 at 11:37 am
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.
March 5th, 2007 at 7:26 am
Exactly. The php5 fact lets me still undecided between the two.
March 5th, 2007 at 11:24 am
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.
March 6th, 2007 at 12:18 am
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
March 6th, 2007 at 12:21 am
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
March 7th, 2007 at 12:14 pm
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.
March 17th, 2007 at 12:22 am
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
March 18th, 2007 at 7:45 am
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
April 8th, 2007 at 11:38 pm
The Cake google-group is awesome, but the IRC channel is really the best place to get help.
April 10th, 2007 at 8:04 pm
Thanks, I’ll check that out.
- Dustin Weber
April 13th, 2007 at 9:02 pm
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.
April 19th, 2007 at 9:28 am
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!
June 12th, 2007 at 3:17 pm
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.
June 12th, 2007 at 6:46 pm
@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
June 14th, 2007 at 1:33 pm
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
July 16th, 2007 at 4:10 am
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
July 16th, 2007 at 6:44 pm
@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
July 17th, 2007 at 12:41 am
-> Dustin
Thnak you very much for your advice
hey very small AJAX with cakePHP ( pretty cool )
http://demo.grahambird.co.uk/tasks
July 20th, 2007 at 1:14 am
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).
July 24th, 2007 at 7:49 am
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?
July 28th, 2007 at 11:21 am
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
January 15th, 2008 at 12:08 pm
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.
February 28th, 2008 at 8:32 pm
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.
October 26th, 2008 at 11:36 am
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.