Aug 07

CakePHP RC2It has been a while since I’ve written much about CakePHP (let alone anything on my blog), but I thought I’d update the world with my latest thoughts in case anyone was interested.

I’ve come a long way since I first started using CakePHP.  In fact, I’ve now used the product on some fairly high end sites and had really good luck with it.  There have been minor quibbles here and there (still revolving around documentation mostly), but I’m now a solidified “Baker” through and through.

I will save you some time looking elsewhere and reading the reviews about all the different PHP frameworks; use CakePHP, it’s the best.  In my humble opinion, the only better framework available is Ruby on Rails (which I’d also highly recommend); but if you are stuck using PHP – CakePHP is your best bet.

This framework will encourage (and teach) you to follow through with good web development habits.  These skills are both in programming style (using standardized naming conventions, proper variable scope, documentation, et cetera), but also in technical areas as well (proper database modeling, mvc  code separation, secure user input validation and cleaning, and efficient function development).

Now that I understand the majority of the tenants of Cake, I can say with confidence that it’s a quality product.  1.2 RC2 solved almost all of the minor/major problem I had with the framework and it seems stable as all get out.  Cake will help you use fast, efficient, and complex SQL queries without a sweat.  It will allow you to create fancy “web 2.0′ esque” sites using AJAX and fancy doo-dads with ease.  It will easily validate your input data without the need for you to much of anything.  It provides easy ways to offer web services, shell scripts, and test your code quickly and easily using SimpleTest.  …And that’s just scratching the surface.  The other advantage is it’s super easy to pull in outside code into your projects using components and helpers.  The framework is rigid where it needs to be and flexible in the areas that are key.

In simple terms – “Cake Saved My Life“.

So How Do I Learn It?

You need to learn the basics of PHP first; I think this writeup is an excellent starting point (though I wouldn’t recommend wasting any time with the Zend framework).  I’ve seen a few people on the web talking smack about CakePHP, when the problem was that they really didn’t understand PHP.

Once you have mastered the basics of PHP, go to book.cakephp.org and read the whole thing on version 1.2 of Cake (currently RC2); don’t waste your time learning 1.1.  You can read it in just a few hours and you don’t have to understand it all at that point.. just try to grasp the basics.  If you’ve never worked with the MVC design pattern, then read those sections over a few times until you get it.  Then, install it using the specific directions in the book (read it carefully).  Now is the time to start using Apache2, MySQL, and PHP 5 if you aren’t yet.  I don’t care if you are Windows, UNIX, or Mac… use the products that are the most popular and you’ll make your life easier.

After you get it installed, make up a wild test application in your head and sit down and code it.  Don’t worry about making it pretty; just learn how to code it right.  Learn how HABTM’s work, learn how automagic form validation works, learn the ajax helper details — learn it all!

So to review:

Dustin’s tips to mastering CakePHP:

  1. Learn PHP (Don’t waste your time messing with Zend though)
  2. Read The Book (learn version 1.2)
  3. Install It (Use Apache2, a recent release of MySQL, and PHP 5… no matter what OS you are on; break your IIS addiction or PHP 4 addiction NOW)
  4. Create a test site in your head and finish it within a reasonable time frame.  Force yourself to finish it.
  5. Love it

Almost every problem you’ll come across should be answered in the CakePHP book now; so no excuses for not being able to get it going.  If you have configuration problems, make sure you search through the Google Group; it’s a vastly helpful resource.

Also, don’t forget to look through the Bakery, you can find a ton of code in there to help you solve common problems.

34 Responses to “CakePHP – The Best PHP Framework”

  1. Rakuli Says:

    Ignore first one, sorry — something went wrong….

    I am sorry to say that I agree with very little contained within this post and read through with ever-increasing confusion as you detailed the reason you find cakePHP to be the best in a large, and in my opinion high quality, collection of PHP frameworks.

    Your description is accurate and conveys what cakePHP does but I am entirely opposed to labeling it as “best PHP framework available” and gasp in surprise when you say that the only better web development framework — regardless of language — is Ruby on Rails.

    Ruby on Rails is the equivalent of Apple in the web framework family — take a look at the RoR project site and then put an ‘i’ in front of their acronym. iRoR — sexy marketing with enough well written copy to convince many that it is a “must have” or in the case of a framework, a “must learn”. RoR is a very useful but in the same way as an iPod restricts you to using proprietary software and audio formats, RoR has restrictions that doesn’t allow a new user to do too much outside of the framework’s blueprint. It would be a boring neighborhood if all our homes were built from the same schematic.

    I’ll touch more on the frameworks in other languages later but for now I want to address some concerns I have with why you believe cakePHP to be so inherently superior.

    This framework will encourage (and teach) you to follow through with good web development habits. These skills are both in programming style (using standardized naming conventions, proper variable scope, documentation, et cetera), but also in technical areas as well (proper database modeling, mvc code separation, secure user input validation and cleaning, and efficient function development).

    It is very unlikely that any framework will encourage or teach a user any development principles . The idea of a framework is to take the abstraction away from the client coders so it is entirely possible for a user with 1 week of PHP experience to commence using a framework and never learn a thing about what is happening in the background. The MVC, bootstrapping and Front controller methods of programming would be entirely lost on them because they have always used a framework that sorted it for them.

    The next few points you mention here are not specific to cakePHP and in fact, if cakePHP did not incorporate them it would be crossing the line to call itself a framework at all. Naming conventions are just logical to allow a framework access to its many parts through uniformly named components and a featured ORM is not only required by all frameworks, it is implemented far better in Symfony, Django, RoR and Codeigniter. Secure input cleansing is also another part that cannot possibly be omitted from any self respecting framework and cake’s validation inside of models is confusing at best and bewildering at worst.

    I have worked on many projects with cakePHP and there are many things that it does well but many many more that it does below par to the point that its disadvantages tilted the scale forcing me to cease using it.

    The worst part of the cakePHP project is by far the documentation, both on the framework’s website and within the code itself. It appears that half of the core developers did not deem appropriately commented code important and it is only now that the fully commented packages are beginning to appear. The ‘manual’ for the development version is still missing a majority of the documentation for anything deviating from the pick-up-and-play parts of the framework and the IRC rarely yields help beyond a request for a paste-bin and perhaps a link to a rudimentary manual page.

    Another completely valid concern I can raise is the appallingly long time that version 1.2 has been beta and now finally being offered as a release candidate. The fact that the beta and RC process continues so long is not the issue, the issue is that the core development team and support areas basically dropped continued support on the much less useful and feature-rich version 1.1 and it is just not conceivable for enterprises — looking to deploy solid applications — to use a framework that is not stable.

    Now that I understand the majority of the tenants of Cake, I can say with confidence that it’s a quality product. 1.2 RC2 solved almost all of the minor/major problem I had with the framework and it seems stable as all get out. Cake will help you use fast, efficient, and complex SQL queries without a sweat. It will allow you to create fancy “web 2.0′ esque” sites using AJAX and fancy doo-dads with ease. It will easily validate your input data without the need for you to much of anything. It provides easy ways to offer web services, shell scripts, and test your code quickly and easily using SimpleTest. …And that’s just scratching the surface. The other advantage is it’s super easy to pull in outside code into your projects using components and helpers. The framework is rigid where it needs to be and flexible in the areas that are key.

    It is safe to say that cakePHP is a quality product. It takes many hundreds of hours and many experienced developers to put together a framework. It is not so safe to say that cakePHP is best.

    Cake does not help you write intelligent queries, it makes you use a ridiculous amount of arrays to get limited amounts of data. The main problem with the way that cakePHP interacts with databases is the lack of flexibility and the eye-wrenching hard time you will have finding documents to inform you of any configurable options you have.

    As for ajax — a pickling point for me is that the ajax features are implemented using prototype with no options to use another library. The 1.2 ajax features are virtually undocumented and if you have no experience with prototype.js you are in a bit of strife. During my development time with cake, it was much faster for me write custom ajax handlers using either my own javascript or a library of my own choice.

    Again, it appears that you have not used many frameworks because all of them allow almost all of this.

    You need to learn the basics of PHP first; I think this writeup is an excellent starting point (though I wouldn’t recommend wasting any time with the Zend framework). I’ve seen a few people on the web talking smack about CakePHP, when the problem was that they really didn’t understand PHP.

    I have been developing applications with PHP for nearly a decade, I can safely say the reasons for my cakePHP dislike is not due to lack of PHP knowledge.

    Symfony, is by far the best PHP framework and I can understand why many inexperienced PHP programmers would prefer a framework like cake which is kinder on those using sloppy coding practices. Symfony implements intelligent use of .yml and x.xml files and understands that when you are using a framework and have to write code — it should be business logic, not drivel to get a view to work — the configuration files get the framework up and running allowing you to quickly snap your logic together.

    In simple terms – “Cake Saved My Life“.

    I have heard this bold declaration from many people — not exactly in relation to cakePHP but essentially in relation to the first framework they experienced. If you have not developed large applications in a modular, MVC or OOP environment, it is a revelation to have all that work done for you and to see things just work…. The statement from above should be

    In simple terms – “{INSERT FRAMEWORK} Saved My Life — Now let me find a better one“

    You may be lucky enough that the framework you first use is the best but you shouldn’t assume that the revelation your first brought you will automatically be the best…

    Now onto why RoR should not claim the first spot on web framework leaderboards…

    RoR has a few things going for it. One large part of that is that RoR was one of the front-runners in rapid development frameworks. It’s quick, it’s “magic” and it has a pseudo big business marketing team behind it but it is limiting, hard to re-use and hard to get set up on a server. In my opinion, RoR is more glitz than guts and this is fine for people who want cheap web thrills on the cheap.

    My heart, my development soul lay to rest at the feet of Django — the massively well documented, passionately well supported and incredibly versatile and modular Python framework.

    I have been coding in Python for some time and anyone else reading this who has used Python will completely agree that it is a sexy, sleek logical language. Django takes the clean Python bull by the horns and harnesses it for deployment on the web. You first Django application may take a little while to set up but the enforcing of modular design and Python’s intolerance of bad scripting practice means you *will* learn how to develop smartly and along the best practice lines.

    Of course this is all relative to where you stand but I wanted to say that you have not convinced me anything more than that cakePHP is another web development framework.

  2. Luke Says:

    hi Dustin, nice write-up. I think I have been using Cake as long as you now, and feel really happy that I chose the best PHP framework. There has been excellent growth in the communtiy in the last year (there are blogs everywhere now) and the serenity of the dev team in bringing cake to a stable, sustainable level is amazing achievement.

    It always had potential, but I think it has been realised now and it is simply outstandingly useful.

    A couple of other things for a newbie to get going with it – join the google group and subscribe to the email daily digest – just read it when you get a spare five minutes and you will quickly get familiar with aspects of Cake.

    Also, the David Golding book just released is worth getting imho. The other book is OK, but I found not too in-depth.

    The bakery is nice to have a look at others code – running through the odd tutorial and looking at the way others use cake will give someone a handle on it.

    And finally the blogs I mentioned – there are about 10 essential ones now, and whenever you google cakephp and something then add the RSS for any tips you find. Thats how I got your RSS a while ago I think!

    cheers

    Luke

  3. Wil Sinclair Says:

    Why do you say you wouldn’t recommend wasting time with Zend Framework? Some of our components address functional areas that CakePHP hasn’t yet, and it will work very well as a vendor library. I’m not trying to change your opinion about ZF- just wondering what is behind such a broad recommendation. :)

  4. Jim Kane Says:

    Rakuli, you obviously have a lot of experience with PHP frameworks so it was good to read your comment. However, I have developed in Ruby and Rails for about 3 years (and PHP since 1998-ish) and I don’t find the rails framework to be very limiting at all. As a long-time PHP dev (and a perl dev even before that) I found the ruby language to be much easier to write, and write well in, than PHP. I still use PHP for some projects (and Ruby has plenty of room for improvement) but I think it’s unfair to characterize it as just “sexy marketing.” The Screencast was certainly sexy, but if it wasn’t backed up by an easy-to-use system that actually allowed you to produce something useful I don’t think it would have taken off as it did.

  5. Rakuli Says:

    @Jim
    I agree, and the intent of my above comment as not to trivialize Ruby on Rails. In fact, if it wasn’t for RoR, I don’t think that rapid development frameworks would have arrived so quickly into the mainstream developer community.

    The sexy marketing hype behind RoR is a very powerful thing and in exactly the same way that Apple has the quality of “i” technology behind it, RoR has a quality framework behind the gloss. In my experience with RoR though, I did feel that I was slightly limited in my choices. I commenced working with Django at around the same time so it is possible that my attention was stolen by Django before I could invest an adequate amount of time to RoR.

    Almost all of the successful frameworks available have a lot to thank RoR for and I by no means wanted to take a stab at it, I just wanted to put my opinion across as to why I think there are better frameworks — namely Django — available.

  6. ajmacaro Says:

    sorry for off topic. but i think you should include “year” on your post date.
    and i cant find a contact page. overall, nice site.

  7. Ivan Jovanovic Says:

    When I started with MVC and using PHP frameworks I created my own first, it was good, fast but not to functional for RAD. After that I developed apps in CakePHP and thought that it is really great, on the line to mark it best, but over the time, as applications I needed to develop were moving from simple to complex and from “who cares” to “care about details, architecture, scalability, maintainability …” I have found zillions of problems that I could not solve in such tight coupled framework. Then I moved to Zend Framework development. I still think that CakePHP is great framework but just for the purpose it is made, fast and dirty development, for something serious like product development and serious business software I’d prefer more decoupled frameworks, Zend is the best in the field currently and there are no arguments to fight with that.

    See my blog post on CakePHP vs Zend topic
    http://tinyurl.com/62vqja

  8. Eugene Says:

    I am seaching for some idea to write in my blog… somehow come to your blog. best of luck. Eugene

  9. Hans Says:

    Actually the best PHP framework is… PHP!!!

  10. phpnut Says:

    CakePHP sucks, it is by far the worst framework I have ever used (for any language). Why people persist with it is beyond me. Maybe it is just plain ignorance (I hope for the sake of all sanity that this is the case).

  11. Harsha M V Says:

    I am taking your advice and starting cakephp.. Will get back here in a few days and post my review and experience.

    Thanx Dustin

  12. Wes Grant Says:

    Really should check out Zend Framework. Far superior to Cake!

  13. Liam Says:

    Hello, was wondering if you can do a review of Akelos? http://www.akelos.org/ What do you think? Here’s the frameworks guide: http://www.phpframeworks.com/

  14. Chris Robbins Says:

    I completely agree with Wes :-) TTYL

  15. Dustin Weber Says:

    @ Wes Grant & @ Chris Robbins:

    HAH – nice to see ya’ll are still stuck in your ways. Some things just don’t change! wink

  16. Karuppasamy Says:

    What Is The Theme you used for the word press. It is Look Very Nice and also put the tinymce and smiles for comments it also generate more look to your blog.

    With Regrads

    P.karuppasamy
    ( Developer in php )

  17. Brandon Says:

    I wouldn’t say CakePHP is the worst framework ever… I do feel it is lagging behind the advancements of PHP5 and could also use some code cleanup. I noticed some of the classes use PHP5′s new features, while the rest of the classes are still using the PHP4 style with “var” and assigning by reference using “&”, where in PHP5 everything is by reference by default. I’m also noticing as I’m going through more of the framework that It appears as if some things have been neglected for quite some time… Also while I was looking up how to integrate smarty into Cake, I found that the SmartyView wasn’t even functional anymore… So I’ve had to recode that. I also find the site a little hard to navigate. I’m tempted to start my own framework that is a lightweight hybrid between Smarty and Cake.

  18. Professional Says:

    I agree with phpnut – CakePHP really does suck. This article is very nice and feel-good, but wasn’t written by an object oriented developer; it was written by a web designer. The ‘pros’ listed for CakePHP are basically that it is a framework (enforces MVC separation, naming conventions, standard modeling interactions, etc), but they are by no means unique to CakePHP. These features are unique to the idea of using a framework. I would suggest, if you are a run-of-the-mill web developer and you want to put out a simple site with simple database schema and no complex application logic, then give Cake a shot. Its V/C libraries are decent, and its development cycle is rather clean. But if you want to do any real database- or logic-intensive work, then PLEASE, do yourself a favor and at a MINIMUM, swap out Cake’s model layer for something real (I would suggest Doctrine) – or do yourself a real favor and use a mature MVC like Symfony.
    I use CakePHP and I have been a backend developer for around 20 years (10 years professionally), and it is common in my workplace to write more code to work with Cake’s model layer than I am saving over using no model layer at all. And as any OO developer knows, this also translates into code that is completely un-maintainable.

  19. Fred Says:

    There are a few problems with CakePHP.

    1 – It is slow, really slow. I find it pretty incomprehensible how they managed to write a framework that is slower than Drupal a full blown CMS. It is also pretty heavy on teh memory compared to other PHP frameworks.

    2 – Documentation, it really isn’t very good. Nor does it help information seems to be spread out all over the place.

    3 – The project manager and lead developer left the project.

  20. dave Says:

    if you need a good ORM like Doctrine then Cake is not the best

    why all your posts about the best symfony have been deleted ? :)

    I’m not sure also you understand what is Zend Framework, which is good for big entreprises applications

    have a good trip !

  21. WebDev since 1995 Says:

    cakePHP like… sucks…

    it’s documentation doesn’t suck because there isn’t one yet.

    it also ranks close-to-bottom on most benchmarks I’ve seen. Rock-solid-bottom on my own benchmarks…

    it is written for PHP4. Not that this matters a lot, but come on… there isn’t even a backward compatibility issue, since anything pre-1.2 is completely unusable.

    I use CodeIgniter and Kohana… experimenting with lithium (PHP 5.3) and for CMS, I like using Joomla (which is a full-blown CMS that beats cake in speed and footprint).

    drop cake. no future there.

  22. Emerson Says:

    Started with Rails and have recently needed to put together a few small projects in CakePHP. Maybe it’s a PHP vs Ruby issue, but I would definitely say that Rails is way more polished, uses beautiful (maintainable) code and has amazing documentation (railscasts.com anyone?).

    The toughest part of Rails seems to be deployment, but that’s changing pretty quick with things like Passenger.

    Either way, CakePHP needs it’s own version of Railscasts.com… or just better and broader documentation. I was initially really excited to get back into PHP and learn another framework, but the lack of solid documentation has been draining so far :-(

  23. CakePHP – The Best PHP Framework | The Weber Report | Velocity Software Solutions (P) Ltd. Says:

    [...] prefer a framework like cake which is kinder on those using sloppy coding practices. …More: CakePHP – The Best PHP Framework | The Weber ReportReturn to topTagged: basics, cake-which, few-people, php, problem, really-didn, sloppy-coding, [...]

  24. Toan Says:

    user Cakeui CMS, it build on cakephp framework, a bit like drupal CMS

    http://cakeui.com

  25. Robert Penwarden Says:

    What is captcha code?, pls present me captcha code codes or plugin, Thanks upfront.
    35

  26. Alex Says:

    Try Symfony, best Framework there is…

  27. Baljit Says:

    cake php is best framwork.

  28. Layton Says:

    For anybody who is going to try a php framework for their first time, use CodeIgniter. Their documentation is wonderful and the framework itself is very powerful. The only thing it lacks is a good template system, which after your first go at it, you end up creating one that fits your style. Not all of us our 10-year veterans and all the “Good Practice” gets in the way of being productive when you still not sure what your doing. As you become better your desire to make better, cooler applications will force you to learn whats going on in the back ground.

  29. Jim Says:

    CakePHP sucks ass! I am looking at the SQL generated by a bunch of .PHP developers and it’s by far the worse SQL I have ever seen. OMG, I don’t know if it’s the developers/CakePhp fault but SQL queries that bring back EVERY COLUMN FROM EVERY TABLE when the system does not need it.

  30. Naveen kumar Says:

    CakePHP sucks!! wasted so much time in learning… Its better to work directly in PHP …

  31. Steven P Says:

    CakePHP sucks. Why? Their blog tutorial INVARIABLY delivers a controller not found error.

    If those idiots cannot make a foolproof “hello world” … well then, ’nuff said.

  32. Steven P Says:

    Fully agree with Naveen in comment 30. PHP is a long time friend of mine.

  33. Steven P Says:

    Agree with Layton in comment 28: codeigniter is WELL documented and worked out of the box.

    CakePHP: when ambiguous documentation is your goal.

  34. kodok Says:

    cakePHP is suck! too many rules,too many magic!
    kohana is the best what you type is what you get!

Leave a Reply