CakePHP
CakePHP Digest #5
News
This is my third digest and for the first time there isn't a clear lead story. I was going to go with gwoo's message that CakePHP 1.2 had received close to 25k downloads in the first 6 days of its release. That works out to 1.5 million downloads extrapolated over a full year. Actual download rate will likely taper off - I just wanted to use the word extrapolate.
Also of interest was Daniel Hofstetter's (cakebaker) declaration of his framework free agency (on twitter too). But then his first post after this announcement was about CakePHP. Since that post launched a fairly long comment thread let's skip right to...
Tickets and Commits
The debate on cakebaker's blog centers around whether bugs (for the stable release) should be accepted without test cases. The census seems to be that the Cake devs are too strict and close valid defects with "needmoreinfo." I can see both sides of this. Some of the defects referenced in cakebaker's post SEEM clear and valid, but were closed anyway. For example: #5943, #5946 and #5951. These have all since been re-opened, but won't be worked on until a test case is provided. You can see the full report of these type of tickets here.
On other hand take ticket #5960. Although to the poster the ticket may be clear and there is code attached, how long would it take someone to actually understand what's going on, especially with some of the comments being in another language?
So is it better to have a clear policy universally applied to all bugs or for the devs to make arbitrary decisions on which ones they'll make an effort to understand? Either way someone's going to bitch about it.
In The Wild
A bunch of new sites to talk about. The first demolistic.com by Tyler (I don't have a blog link or twitter account. Tyler if you read this ping me for a link). Tyler wrote about his experience building the site on The Bakery. A competing site to Tyler's Demolistic is MakeFive.com (not a CakePHP site (that I know)). One of the creators of MakeFive wrote a post called "Why your web startup will fail," which has nothing to do with CakePHP, but I thought was a good article so I made a tenuous connection to it through Demolistic, which is CakePHP related.
Also written up in the bakery is Jeffery's releasedatez.com. I recently launched a similar site, so I'll give Jeffery some friendly advice. As great as you think the site is, 99% of the three people that try your site will forget about it with in a day of first using it. Right now it appears the only way to see if an item released is to log back in. You need way more ways of notification: email, rss, facebook to start. Also everyone should make sure to check out the screen cast on the about page. The narrator (Jeffrey I assume) has that whispery, calm serial killer voice. When CakePHP digest #6 isn't published in two weeks, you can assume I'm tied to a chair listening a description of how my innards are going to be made into balloon animals while I watch.
In The Blogs
I always like to read posts about little Cake functions that I didn't know existed. I still remember the first time I read about Set::extract - it was like I was 10 years old and discovering Halloween (the movie) all over again. cakealot has a quick post explaining the String::insert that is worth checking out.
Chris Hartjes has a nice post refuting pretty much everything said in this post comparing CakePHP and symfony. Kudos to Chris for his post, but mostly for actually getting through the original comparison. I started to read it to see what quippy little jokes I could make, but slipped into a 20 year coma after 3 lines. Fortunately WordPress version 47.3 has a cool feature where you can back publish posts and they will actually appear back in time, which is why you are able to read this.
In The Groups
The Yii framework published report of performance benchmarks comparing the top PHP frameworks. Pretty much anything intelligent that needed to be said was covered in this discussion - which still leaves me plenty of room for unintelligent slams. Like this one: Watch now as I invalidate the entire results of the comparison with one sentence QUOTED DIRECTLY OFF THEIR PAGE. You ready? "each application is written such that a single die('hello world'); statement is placed in the default controller action of each application." Check out the CakePHP controller used.
The Yii Framework: Just when you thought "Hello World" couldn't run any faster.™
I feel obligated to link to this thread, a debate about X/HTML standards, which is educational, entertaining and horrible depressing all at the same time.
This thread linked to one of most perplexing programs I've seen in awhile, the ModelBaker application. Basically they took the Cake console, made a GUI (that runs in OS X only) added a few extra features and are selling it for $399. But then they didn't really dumb down any of the Cake lingo, so you still essentially have to learn Cake before you can use it. I spent 4 hours on their site and figured out the target audience is someone with enough programming skill that they understand MVC and CakePHP, uses OS X, doesn't like the command line and only wants to produce CRUD apps.
In The Bakery
There were a ton of new articles in the Bakery, but only one really stood out to me. I was going to make fun of this article, but it's since been pulled from the bakery. So instead I'll mock the original source. The idea is to use "lorem ipsum" text throughout your application, then replace that with the actual text using CSS selectors and JavaScript. Frankly the whole concept is so absurd, I'm going to assume this is an elaborate practical joke. Like the author is going to build a huge install base, then release a version where all the text is replaced with "The developer who built this site was dropped as a child. Several times. On their head. Contact tobiasz.cudnik@gmail.com for competent web development."
And on that note don't forget to subscribe to my feed or follow me on twitter.
As always if you think I missed something leave a comment. Or if you do something interesting and want it included in the next digest, send me an email.
CakePHP Digest Volume #4
News
Wow. I figured with the holidays and New Years coming up there would be no news to write about. Was I wrong. If you haven't heard the major news then you must have been frozen in carbonite for the last two weeks. I mean if this is the first time you're hearing this historic announcement then how can you consider yourself a CakePHP developer? That's right - it's finally been released...the best version of CakePHP ever...RC4!!!
In other less noteworthy news, 1.2 Final was also released. My favorite 1.2 announcement post was this one, which came two days after the release, but was still titled "Breaking news." Also the author somehow missed reading about the release here, here, here, here, or here, and admits they heard about it after being notified by roryy.
To celebrate the release of 1.2 there is a new "The Show" podcast featuring Rafael Bandeira interviewing Nate. Noteworthy bits in the podcast include Nate hinting at JavaScript changes for 1.3 and promising that there will never be such a long gap between releases. By my calculation that puts the release date for CakePHP 1.3 as 12/24/2010. Mark it down. (Not to harp on the time between releases, but I had to correct the subconscious typo "CakePHP 1.2 Finally" like 10 times in this post.)
Also in the podcast Rafael and Nate said some kind words about this blog, which was surprising and appreciated. If I hadn't got this sweet 22in monitor for Xmas that would have been the highlight of my week.
One last thing about the podcasts in general. If Nate doesn't get a new microphone by the next one, I'm going to start filing core bug tickets with titles like "Nate should be allowed in the room for podcasts instead of having to shout through that closed window" and "Nate should use a text-to-speech system for future podcasts." Seriously, can we get a new donate link on cakephp.org specifically for this cause?
Tickets and Commits
There are four tickets at the moment for 1.2 Final, but only one of them has been assigned and it's related to Oracle so it really only effects like one person. It took 15 commits to go from RC4 to Final, closing 5 tickets along the way.
In The Wild
One new CakePHP site since the last digest. The site is shhh.tv and although it's flash heavy, Mark Holt writes that the backend is all CakePHP. So if you're in the mood to answer a long and tedious questioner, where the payoff is a sketchy looking Santa giving an un-funny gift suggestion, then this is the site for you.
In The Blogs
Lots of good blog posts over the last two weeks. Chris Hartjes launched a Framework Apocalypse t-shirt, which I would describe as wildly inaccurate, seeing as the zombie frameworks are presented as a unified front, when in actuality they would be bickering among themselves.
teknoid posted a simple way to build a dashboard style page. I had forgotten you could call methods on the models returned by ClassRegistry::init directly, skipping the need to set them to a variable first. Actually I didn't even know this was possible, but I never admit to not knowing things, it makes me look weak and my enemies will use that to crush me.
Mark Story has a really good post on unit testing controllers. Unfortunately testing controllers in CakePHP is a bit of a pain at the moment. It would be awesome if you could use the ClassRegistry::init to create the test controller and that would automatically set up the controller as a test instance. Kind of like how models work now.
In The Groups
The full list of CakePHP 1.2 Final features is listed in the bakery announcement, but I think we can all agree that the #1 most important feature of this release is never having to answer the "Should I use 1.1 or 1.2 for my new project" question in the Google group again. Of course you eliminate one annoying re-occurring question and another pops up. Like this slew of discussions about response time (1, 2, 3).
The first thread linked seems to hit on an issue I've seen before: MediaTemple hates CakePHP. I would take a perfectly fine app and drop it on MediaTemple's GridService and the thing would be unbearably slow. Fortunately I haven't had to deal with MT in awhile, but sc0ttman links to this post, which he claims solves the issue. If I had know about this 6 months ago I'd only be half the alcoholic I am now.
Random Links
I've already commented on this enough, but for those that missed it or just want to relive the "Four reasons to hate CakePHP" fun: go here, then here and finally. In hindsight, I'm starting to think the whole thing was a masterful attempt by A.J. Brown to score some new readers. He probably has a bunch of CakePHP acolytes now waiting for him to even think a bad thought about Cake so they can jump all over him again. Not sure if that counts as a win or not.
According to this poll, CakePHP is the most popular PHP framework. So that means you're currently reading the 47th most popular blog for the #1 most popular framework. You could be doing so much better right now.
I will link to this without comment. You are free to interpret it on your own. If I were to comment, hypotheically, I would probably include a link to this.
In The Bakery
There was one new project in the bakery and I must say it's pretty awesome. It's a flexible revision history behavior. Not to backseat code, but I probably would have gone with one "shadow" table with a text field where you could serialize the model data (and any related models data) to store all the old revisions, rather then a shadow table for each model. Then again, I'd rather remove my fingers bit by bit with a deli slicer then actually write a revision history system, so who am I to judge?
I'm Out!
And on that note don't forget to subscribe to my feed or follow me on twitter. I'm trying to get over 200 RSS subscribers and 50 twitter followers by the end of the year, so if you read this far it must mean you're moderately entertained. PseudoCoder.com: Your source for extremely niche, moderately entertaining reading.™
As always if you think I missed something leave a comment. Or if you do something interesting and want it included in the next digest, send me an email.
.8 Reasons to hate CakePHP
I'm still bored and lacking posting ideas, so I figured I'd give a hyper-critical breakdown of "Four reasons to hate CakePHP" by A.J. Brown. Let's get right into it.
Before starting a project recently, I spent some time doing some research comparing CakePHP and Zend Framework for rapid development. I noticed that of the few articles out there, not many of them where able to offer any advice on using either framework for a new project. In most blogs, it seemed to come down to preference. My goal today will be to steer you away from Cake.
Granted I'm not really the target audience here, but I can keep an open mind. I can't make the same promise for my cat (coincidentally named CakePHP), who will most likely hiss and spray urine at my monitor as I read.
Cake is Heavy
Staying out of your way is a very important for many aspects in life, including your application’s third-party framework. You want something that provides functionality and structure, but allows you to fulfill your own needs in your own way.
On the same page so far. Let's see how this is a negative in respect to Cake.
There’s nothing lightweight about it. Cake tends to get in the way of your application by requiring your application to be built on top of (instead of along side of) itself.
I'm not really sure what the difference is between "on top of" and "along side of". I'm guessing this is the difference between using a framework and a library. I blame Zend for confusing this issue.
When cake is bootstrapped (configured), it will look for your application specific configuration files in a hard coded file location that it expects.
Just so I'm clear: A.J. wants a framework that "provides functionality and structure" but complains that config files are in a certain location. Isn't that part of the structure? Also, I think A.J. and I have a different definition of "heavy". This section should have been titled "Cake is Unflexibilityness."
Although you can predefine the defines (which is a whole-other reason to avoid using cake) it uses to determine paths, you’ll never be able to completely seperate cake from your life without modifying cake itself.
I don't understand why people would expect to be able to write an app using a particular framework and then be able to separate from that framework at some point in the future. Thats like switching to an unprimed canvas after painting your masterpiece on a titanium dioxide and calcium carbonate, bound with a thermo-plastic emulsion primed canvas. Who does that?
One of my cleints’ websites is was written on top of one of the Cake 1.2 alpha releases from a few months ago. (By the way, did no one tell the developers that in software engineering “alpha†release is not meant for the public?
A.J. has a point here. When an open source project releases an alpha version they should, at minimum, require a secret handshake before allowing the community to access it. Also, I remember when Cake 1.2 alpha first came out I didn't want to use it, but then Nate showed up at my house and bullied me into it.
I recently upgraded to 1.2 Release Candidate 4 and had a few problems. This is to be expected when you’re using any non-stable version of anything, but what I didn’t expect was API changes. I don’t mean additional features, I mean changing APIs. Granted they were few and far in between, but they were still unexpected.
To summarize: A.J. used an alpha release (probably against his will), jumped something like 17 releases to RC4 and was surprised by minimal API changes.
Hanging on to Old Times
The most annoying thing to me is that Cake uses PHP4 style objects. I feel safe in saying that any community software being developed today that believes hindering best practices in order to support an obsolete (in the loosest of terms) version of software is not very forward thinking. No class members or functions have access modifier, and I don’t remember seeing any type hinting whatsoever.
A somewhat legitimate complaint to those of us who've moved on to PHP5. I see this all the time and I don't think people realize that even though the framework is PHP4/PHP5, there is NOTHING preventing you from writing YOUR code in PHP5.
No Namespace Consideration
Cake uses very generic class names with no consideration for names pace[sic] collisions.
Pace is very important when dealing with rapid development frameworks. The fact that Cake has no consideration for pace leads to thousands of collisions and hundreds of deaths a year. Factor in the increased alcohol intake of CakePHP developers and you have a recipe for disaster.
By using cake, you’re forcing yourself out of using generic class names in your own application (which is a better place for generic names to be!). Want to name a class `Controller`, `App`, or `Model`? Too bad — cake has claimed those names for you!
Another somewhat legitimate complaint. I actually hit this issue once...in two+ years of using Cake...and moved past it in like 5 seconds. Here's a quick guide for some alternate names:
Controller: BossMan, Model: SheWhoWillNotLookAtMe, App: ThankGodImNotUsingJava.
Another horrible practice of Cake’s is using global functions. Hsughughugh.
I think "Hsughughugh" is an aggravated pounding of the keyboard. Which is odd since A.J. wasn't so aggravated that he didn't miss capitalizing the first word. Also check out the letter selection. Seriosly, try randoming banging at your keyboard. asdfhnasdlk. Again: k;lajsdfaksfd. Generally you get some mix of the home keys. A.J. must be using one of those crazy new ergonomic keyboards.
I cannot begin to tell you how painful and fragile this is. All it takes to cure a few of the problems this creates is to wrap them in an abstract class! I don’t know why they would rather have the function uses() in a global namespace instead of wrapping it in a class as `Cake::uses()`.
Um, this was changed like 3 releases ago.
Some (maybe most?) have been fixed in RC4 (you use `App::import()` instead of `uses()`), but they still allow the abuse by keeping the functions there.
This is just silly. He complains about something from an old version, then acknowledges it's fixed. You know what I hate about watching TV? Having to get up to change the channels. True this was fixed with the invention of the remote control, but they still left the ability to change channels on the TV itself.
Also, I'm pretty sure A.J. complained about changing API earlier in this same post. But now he wants the function removed.
Conclusion
If you are reading this article, you’re probably at a crossroads between using CakePHP or using some other suite.
Or someone who enjoys nitpicking other blogs.
I could go on and on about why I personally hate cake, but when it comes down to it, the decision is yours.
Unless Nate puts you in an armbar.
Despite my gripes, Cake is still a good tool to get a simple website up and running quickly in a structured manner, without reinventing the wheel.
CakePHP is actually against developing serious sites using the framework. They keep a running list of the offenders here.
Just make sure your website will never need to be scalable, and that its codebase will never grow beyond the small flexibility it offers.
Oh shit. Cake just got Rudy'd.
I’m personally experiencing this pain right now.
You think that's pain. Just wait until Nate puts you in a figure four leg lock and forces you to write "25 things I love about CakePHP in haiku format."
I will give credit to A.J. for breaking from the "Hate CakePHP Playbook" and not slamming the documentation. So +1 for that, +.8 for legitimated points, -138 for weak points. I give this article a 2 out of 10 (not an aggregate of the points).
CakePHP Digest Volume #3
Previously On...
I've decided to do bi-weekly posts about the latest happenings in the CakePHP world. I'm starting with #3, since Christian Winther had previously done #1-#2 on his blog. I emailed Christian to make sure he was cool with me picking this up, so in the same vein, when I fade out around digest #6 anyone reading this can feel free to pick up the ball and walk with it (don't run though, the ball is made of scissors).
News
At the beginning of the month the 2nd CakeFest took place in Buenos Aires. All the cool kids were there, drinking beers and talking Cake. I missed it, but I'm ready for CakeFest 27 in 5-7 years (with time off for good behavior).
For those who missed it or just want to re-create the entire experience here's some simple steps:
1) Print out each of the pics from the event and hang them in your cell/cube.
2) Grab a copy of the slides from two of the talks (or read write-ups of all the talks).
3) I usually re-enact the presentations with impersonations of the presenters based on what I think they're like. You can simply read the slides - it's up to you.
Tickets and Commits
Instead of simply listing all the commits and tickets, I'm going to try to summarize the current status and maybe point out a few import items. Unfortuatly my plan was shot to hell because there is only one open ticket for CakePHP 1.2. It's hard to summarize one thing. Now I'm going to have to spend the next 6 months earning commit privileges so I can submit some buggy code and have something to summarize.
On the commit side, there have been 21 revisions since December 1st, closing 6 tickets. Mark Story was the most active committer, although he may just be making meaningless changes to get his commit count up so his boss thinks he's busy. Not that I'd know anything about that.
In The Wild
This is the part where I mention newly launched CakePHP sites. Nothing new on the official CakePHP "Sites in the wild" page since December 1. I could plug my own shit, but that seems kind of lame. Leave a comment if you launched a new CakePHP site in the last two weeks or send me an email if you are launching one soon.
In The Blogs
This ven diagram from Debuggable.com caused quite a stir, as some people missed the scientific nature of the diagram and took it for simple humor.
There were also a couple interesting posts about handling environment specific settings in Cake apps. Personally I'm a fan of having a "bootstrap.local.php" file that isn't stored in SVN and is included in the normal bootstrap file. There's no sex appeal to this method though, so if you don't want to be standing alone in the corner while everyone else dances the night away, I suggest you read the posts by Neil Crookes, Chris Hartjes and Rafael Bandeira.
In The Groups
The topic of unit testing came up twice(1, 2), which make sense since CakePHP 1.2 unit testing can be a bit...uh tricky. As an aside: when you have kid(s) it's natural to try to limit the amount of cursing you do in front of them. This has led to me saying "oh my goodness" instead of my usual colorful language. When I was learning the CakePHP unit testing I said "oh my goodness" a lot.</aside>
The other hot topic, that accumulated 21 diggs...er...messages, was about cakephp.org being down. I'd like to congratulate the entire CakePHP team on this accomplishment, since we all know that downtime is directly related to the popularity of the project...just ask jQuery. Thanks, you're a great crowd. Please remember to tip your server.
In The Bakery
Nothing new in the last two weeks, which isn't surprising with CakeFest happening, and the fact that every topic or piece of code that could be of any use to anyone has already been done. Seriously, give me one code related idea that hasn't already been beaten into the ground. Why do you think I'm writing this stupid digest? I haven't had a good post idea in weeks.
And on that note don't forget to subscribe to my feed or follow me on twitter.
As always if you think I missed something leave a comment. Or if you do something interesting and want it included in the next digest, send me an email.
CakePHP Model Test Template
The CakePHP bake utility can create unit tests and fixtures that can be used for testing your web app. Although these templates work fine, they are a bit difficult to maintain, especially as your application grows. I spent some time tweaking the test case and fixtures to make the process easier. All the sample templates are available at GitHub.
Fixture Changes
The first thing you'll notice is that the schema is no longer explicitly defined in the fixture. Instead it will be pulled from the original table, which means you won't have to worry about updating the fixture if you alter the table.
The second change is the addition of the $import line. This tells the fixture which table it should use as the base from the original database. Although it is possible to specify a model, which would then be used to figure out the table name, I found it was best to point directly to the table. If you original table isn't in the default database, you can add a "connection" option to $import for which datasource should be used.
Test Case Changes
The model test case has one important change. To create an instance of the model being testing the ClassRegistry::init method is used. By doing it this way the model instance and any associated models will automatically be set to use the test database. This means you no longer have to extend the original model to override any particular option.
Notes
The setup described above assumes the test database is completely empty to start - no data and no tables. Also, because the original models are used, the fixture for any related model must also be included. This can be kind of a pain for larger databases. I don't have a great alternative to this at the moment.
