Experimenting with CakePHP

CakePHP PHP FrameworkCakePHP is the PHP equivalent to Ruby on Rails. There are quite a few PHP MVC (Model, View, Controller) frameworks for PHP, but I chose to experiment with CakePHP because it seemed to have a pretty complete list of features.

I had started writing a Twitter mash-up in Ruby on Rails, but then after my interview with Alex Payne and some tests our IT guys ran in our hosting environment, I was convinced that Ruby is hard to scale. I was also frustrated learning Ruby at the same time I was learning the Rails framework. Therefore, I thought a PHP framework would be better, since I know how it scales and I’m very intimate with coding PHP.

The similarities between CakePHP and Rails are very striking. I would say the Rails script/generate functionality is a little more polished than the bake.php script in CakePHP but most the elements associated with the various components are the same.

I was able to basically recreate most the code I had written in Rails in the CakePHP environment in less then an hour. I still have very limited experience with both and haven’t gotten into using CakePHP with AJAX yet.

There also seems to be far more documentation of the Rails environment then the CakePHP environment. I think that having so many MVCs in PHP is hurting any single one from growing mass adoption.

Does anyone have some insight into comparables?

This entry was posted in Programming and tagged , . Bookmark the permalink.
  • There is an obvious difference in the number of visitors and application complexity but they recently broke their personal pageview record after being featured on LifeHacker and Digg. Their service survived the traffic without any problems.
  • I never used any interface for PHP i think it sounds good to here about PHP interface i will use CakePHP will see how interface feature will looks like.
  • Matt
    Hey Edward , www.DealQUE.com is an up and coming site built on cakePHP, fairly high traffic.
    Check it out and see what you think.
  • I think that having so many MVCs in PHP is hurting any single one from growing mass adoption.
    I agree.
  • Edward
    I'm trying to find some production high traffic sites running on cakePHP, but am having a tough time finding any.

    Above, I see plenty of references to addons.firefox.com, but when looking up their traffic ranking, it is barely worth mentioning (rank is currently 351,615).. I have an old unused domain name which has a higher traffic rank.

    Is there anything besides addons you can list? The web lists I have found are mere personal blogs or tiny 'web presence' sites. Not one is of note besides possibly store.theonion.com, which you know has very little traffic, as most e-stores do.

    Is there a forbes.com or theonion.com or sonybmg.com type site out there written in cake?
  • Shane: Okay, maybe you could clarify for me... what things don't work now that used to?

    Yes, we've re-arranged a few things in the name of progress, but deprecated methods have always thrown helpful warning messages showing you exactly what you need to change. And up till the lastest 1.2 release, production apps have maintained a fully backward-compatible API in production mode. All changes have been expanded functionality, that does not alter existing functionality.

    As far as your localization question, you can localize any string using the __() function, combinded with a .po file for each language you wish to support. Pretty simple.

    If you'd like to know more, refer to the CakePHP resource sites, or post your question to the mailing list.
  • Oth
    I don't know why people see community is a problem, the google group has nearly 5000 user. the cakephp IRC channel is very active and helpful.

    Oh well.
  • Shane
    Hi Nate,

    I've actually been developing in cake. I'm rewriting an existing app from scratch - not porting any classes that are in cake. I wanted to be as open minded as possible! I've chipped away on my "downtime" and I'm probably 50-60% there.

    Don't get me wrong. I really do like cake. It may just be a framework maturity thing. But my feeling is that when I go from version to version - changes shouldn't be as dramatic.

    This would probably be a question for the newsgroup but here goes anyway. How would you envision integrating localization with the way error messages are set via the form helper?

    In my previous apps, an error message file based on the form and language is loaded via an error helper. Trying to keep things as simple as possible. I'm actually going to do this for my cake app as well.
  • Also, the idea that Symfony scales is largely a matter of perspective. The Yahoo! team that developed Bookmarks hit huge performance bottlenecks shortly after going into production, and had to rewrite several parts of the core framework. Cake, on the other hand, runs many high-traffic sites just fine, including the Firefox add-ons portal.
  • Shane: Have you determined that through actually trying it or are you just saying that because you don't know any better? Here, I'll take this one for you: the fact is, validation in Cake 1.1 is completely forward-compatible to 1.2, and that compatibility will persist through the final, stable 1.2 release. Developers need only update their validation code as their requirements demand.
  • Shane
    Sorry, in response to Scott's link to Cake's validation. That documentation only applies to 1.1. Validation has been rewritten in 1.2 to the point where developers will need to rewrite their code i.e. there is no more pattern matching.

    I'm not trying to be a hater but as a developer I'm looking for consistency. I do like developing in cake :)
  • Shane
    I've been hacking around with Cake. I really like convention over configuration philosophy but more importantly it's implementation.

    The blog example hooks you in but it lacks real world situation, i.e. sanitizing data and validation.

    I would agree that doc's are lacking. I spend my time searching the newsgroup and digging through the API to get stuff working the way I need it to.

    I'm only testing out Cake and I admit is pretty easy to develop but my concern is performance. I won't be committing to any production apps until we've sure it can perform. It's great that Cake is based on RoR but it could also be a disadvantage especially if the framework it the cause of performance bottlenecks.

    I'm also working with CodeIgniter. Not as feature rich as Cake but it's easy to learn. Also CI's community is really helpful for newbies which is how you get developers adoption. Other communities attitude is like just read the API's. Nice - NOT.

    I did take a crack at symfony but found YAML way too much. I know Yahoo has developed it's Bookmark site with symfony. So you definitely know symfony scales.
  • Roj: if you think baking and scaffolding have anything to do with compiling or are even remotely related in any way, you clearly don't understand the purpose of either.
  • Roj
    Code Igniter feels the best - baking apps, scaffolding with scripts seems to "compile-y" to do. I'd rather just unzip, upload, and start building right from the start!

    I do agree on the point that PHP has too many frameworks and that is exactly why people seem to settle on Ruby-on-Rails - because it has MVC built in (via Rails) and they fight the indecision they would have to face if they chose PHP.
  • "Zend Framework" is a bit of a mis-nomer, as it's really not much of a framework. See my write-up here: http://cake.insertdesignhere.com/posts/view/18
  • I think you make a very valid point about too many PHP MVC's but luckily Zend themselves are working on a whole framework (that also includes a MVC)

    http://framework.zend.com/

    It not far off its first release candidate (I am currently using version 0.9.2). Its got some fantastic modules for caching, authentication and Access control levels (plus many more.).

    I have been writing up some of my experiences on my blog http://blog.assembleron.com/

    Any questions give me a shout.
  • lucas
    try code igniter. rocks ass
  • Galen, your statement is basically meaningless: if you throw enough hardware at anything, it'll scale to 11,000 requests per second.

    Hell, even a 'hello world' page on a stock install of PHP running on your average dedicated server is going to top out around 1,000 rps.

    Although I don't have any hard numbers, there are plenty of high-profile, high-traffic sites running on Cake, i.e. the Firefox Add-on portal.
  • JustAnOutsider
    Shanti, you have a great point! except that if your site _does_ end up getting into the twitter/flickr league, you're really in a bind. Rails is a bear to scale and by then you've come a long way.

    It's funny, the developer productivity gets you there faster, but once you do, and you do get lucky, then what you do? keep talking to your one instance of mysql?
  • As has been stated before by many software pundits, 99.999% of webapps will never see anywhere near the kind of traffic of a Twitter.

    I have a RoR app that pushes 25,000 pageviews a day between a few inexpensive servers, with CPU loads averaging .05.

    The vast majority of companies would benefit more from the rapid development nature of RoR, than the scaling benefits of PHP. (when you're talking at a twitter/facebook level)

    Problem is, every entrepreneur is so infatuated with their own idea -- they all think their site is going to be the next Facebook/MySpace/Flickr/Twitter/Whatever when chances are it'll never grow out of 1-2 dedicated servers for the life of the app. (simply the law of averages)

    Best of luck on the new app!
  • Thanks Scott. I wasn't aware of the Google Group or API documentation.
  • Not to be a smart-ass, but I'm pretty confident that no Cake project has scaled to accept 11,000 requests per second yet. Yes, php has hit that, but not the framework.
  • Scott,
    I found lots of starter articles, like Tom says, but nothing describing exactly how to use stuff like activerecords for example. I had to basically search for a specific example of what I was trying to achieve rather then just reference some documentation.
  • Tom Clancy
    I'd have to agree with Josh. When I tried to use it, the lack of useful documentation was a problem. There are plenty of blog posts and getting started articles which would be all anyone needs if you were building the exact application described in the post. Cake seemed to lack the sort of "suck to grind out but needs to be done" API-type stuff. Take a look at the reference materials for Django and then try to find a Cake equivalent. I had to dig through Google just to find out how to implement custom validation. I never did find a reference for the database object types.
  • Josh,

    "The one thing I’ve found lacking in CakePHP is the documentation/community."

    I can't speak to the community aspect since I'm not coding in CakePHP, or PHP at all really, but it seems like there are plenty of documentation resources at the website. I see links to screencasts, two 5-part articles at IBM developerworks, and several linked blogs. What are you looking for that you aren't finding?
  • David,
    I've been playing with 1.1. I've been meaning to try 1.2 and read about the new version of bake.php. The one thing I've found lacking in CakePHP is the documentation/community. Rails has far more resources for learning unless I'm missing some resource?
  • David
    Which version of CakePHP are you using? My background is PHP and after dabbling with Rails development I can to the same conclusion about general performance and scalability. I've come back to CakePHP and have to say the latest 1.2 branch is really coming along. Now bake.php is robust enough to handle habtm relationships with full scaffolding support.
  • When we tested it internally, we were seeing a 3 to 1 decrease in speed when comparing Rails to PHP. Granted this was using Apache as the webserver running RoR through FastCGI.

    I wonder how much hardware Hotspotr had to through at RoR to scale it?
  • Scalability has been the biggest concern with Ruby on Rails, which we can clearly see whenever Twitter has a surge of traffic.

    Andre's blog over at Hotspotr talks about how their application is hosted and setup to allow for scalability.

    There is an obvious difference in the number of visitors and application complexity but they recently broke their personal pageview record after being featured on LifeHacker and Digg. Their service survived the traffic without any problems.
blog comments powered by Disqus