CakePHP

Winner of CakePHP Application Development Book Giveaway

Posted by Matt on Mon, Feb 16 2009

I decided to cut short my giveaway of a copy of CakePHP Application Development. I'm not sure why I originally made the end date Feb 29th Feb 28th. I guess it seemed like a good ending point. In actuality, pretty much everyone who was interested entered in the first two days. There was no real point in dragging it out after that.

The winner is Nick, with comment #3366:

I like cakePHP and I can read; therefore, I’m a perfect candidate!

Congrats, Nick. I'll be contacting you shortly via email to get the shipping info.

The winning comment was picked randomly. Here's the query I used:

SELECT *
FROM wp_comments
WHERE `comment_post_ID` = 400
ORDER BY rand( )
LIMIT 1

Thanks to everyone who entered!

Posted in CakePHP | 4 Comments

Giving Away A Free Copy Of CakePHP Application Development

Posted by Matt on Thu, Feb 05 2009

cakephp-application-development

This giveaway has ended. Here's the winner.

I'm not sure if this is going to be frowned upon, but I'm giving away my review copy of CakePHP Application Development (reviewed here). I figure I don't have much use for it, so maybe someone else will benefit.

Book is in A+++ condition, adult owned, read once. I'll pay shipping. All you have to do is leave a comment on this post - although it would be cool if you signed up for my RSS feed or followed me on twitter. On Feb 28th, 2009 Feb 16th, 2009 I'll run some fancy SQL and select one of the comments randomly.

If you already know Cake it probably isn't worth entering as the book is geared towards beginners. I know some of the core devs spend so much time coding the framework they probably couldn't code with the framework (you know who you are), but please refrain from entering.

Good luck!

Posted in CakePHP | 43 Comments

Did You Guys Know About The CakePHP DebugKit?

Posted by Matt on Mon, Jan 26 2009

You know when there's something out there that you know you will like, but for whatever reason you don't check it out right away. Like the TV show Arrested Development or fleece. That was me with the CakePHP DebugKit. For those even more out of the loop then me, the DebugKit is a CakePHP plugin that adds a bunch of information panels to your app.

If this was your app (it's not - it's mine) and you had the DebugKit installed you'd get that extra panel in the upper right.

DebugKit

Installing

I finally got around to installing it on one of my projects this past weekend. It is so stupidly easy to install, it makes me what to apologize to everyone who has suffered through the 10+ step install process that usually come with my code. My bad.

Here's my running commentary, post install:
+0 seconds - Meh, kind of cool, but not really life shattering.
+25 seconds - It really is convenient having all this information at my fingertips.
+39 seconds - I bet this would have come in handy all those times I nearly went crazy trying to figure out some stupid bug. Plus I would have saved all that time I wasted on GTA IV working out my anger issues on random pedestrians.
+55 seconds - Damn, this thing is pretty great.
+67 seconds - Wait. Why didn't I think of this? I'm such an idiot. *hitting head* stupid, stupid, stupid...
+67 seconds to +2940 seconds - Playing GTA IV. Listening to the song "Disgruntled" by The Randumbs on repeat.

For the benefit of those who have never used the DebugKit here's some screen captures of each panel:

Cake Icon

The CakePHP icon on the far left simply opens and closes the panel. If you don't have the file /app/webroot/img/cake.icon.gif it will say "cakePHP" instead. Small bug there, as it should probably read "CakePHP". I actually feel good about this, because it proves Mark Story isn't perfect. Did I mention this was Mark Story led project (with contributions from others)? I was trying to avoid mentioning this, since he already gets enough good press. How long until cakephp.org reads "CakePHP starring Mark Story"? I put the over/under at 2 months.
dk-open

Session

The session panel gives you the same information you'd see if you did a pr($_SESSION). Not that any of us would ever do that. Let's try that again. The session panel gives you the same information you'd see if you put a break in your code and used Xdebug to look at the $_SESSION var. That's better.

dk_session

Request

The request tab is probably my favorite, but because of the post -> redirect nature of most CakePHP apps it misses out on the most useful information. It would be super helpful if it also had information from the previous request, so that if you submitted a form and then were automatically redirected you would still be able to see that post data. It's too bad the DebugKit isn't open source or I would totally go add that.

dk-route

Sql Log

Ha! Another bug: SQL is an acronym and should be in CAPS! Or is this like the whole Ajax/AJAX thing? You know what? Forget I mentioned it. The Sql Log takes the sqL dump that would normally be shown at the bottom of the page and moves it into a panel. This is great if the sQL output was messing up your design.

dk-sql

Timer

The timer panel gives a break down of how long various parts took to run. I would guess if you are having real performance issues this will just point you to your controller action and you'll be on your own from there. Although if you went nuts using requestActions your views/elements could have long render times. Wait, would this show multiple entries for Controller Action in that case? And then another view render? Will I actually test this instead of endless asking questions? Unlikely.

dk-timer

Log

This panel shows you any new log entries that were made during the request.

dk-logs1

Memory

Probably the weakest of all the panels, which is why it's on the far right. The other panels were like "fine you can hang around with us, just stand over there out of the way." Then they said some mean things about him and even though they thought he couldn't hear them, he did. Frowny face.

dk-mem

Posted in CakePHP | 8 Comments

Book Review: CakePHP Application Development

Posted by Matt on Thu, Jan 15 2009

After completely exhausting their list of every CakePHP blog, Packt Publishing, broke down and sent me a free copy of CakePHP Application Development to review. I was really tempted to write a joke review, where I focus on the binding and typeface (both superb by the way) and show pics of me using the book around the house. Like a shot of my daughter using it as a step stool to get on the toilet or me squashing one of those giant alien bugs that occasionally sneak into my basement with it. Then when they sent me a nasty email, I would play dumb and be like "Oh...you wanted me to review the CONTENT of the book."

But then I realized:
a) That would greatly reduce my chance of ever getting free shit again.
b) This may be my one shot to get quoted on a book jacket (assuming they do a second edition). So throughout this review, as a favor to the publisher, I will be highlighting jacket worthy quotes.

"The binding and typeface are superb." -Matt Curry, PseudoCoder.com

The Boring Part (of this review - not the book)

Now I know how guy #497 of the Houston 500 (link NSFW) felt. There isn't much new to cover, as it has all been said before. I will say the grammar didn't bother me, like it did most of the other reviewers, probably because my mind operates at a 3rd grade level.

The other common complaints: not enough depth (no behaviors or unit testing), poor formatting off the example code and it's based on early 1.2 version of CakePHP, so there are inconsistencies with the final release.

"There a lot of complaints about the grammar and punctuation, and I mean a lot, but this doesn't detract from the overall value of the book." -Matt Curry, PseudoCoder.com

In The Beginning

The first part of the book deals with getting CakePHP setup and starting a simple todo app. If you have even a modest amount of CakePHP experience you can skip the first third of the book or so. I will give the authors credit for not walking the user through setting up a web server and database. Although that credit is immediately taken away when they devote three pages and four screen shots to downloading Cake. I think if I were learning Cake for the first time this section would provide some value. There are decent code examples that are immediately re-enforced with a description. At times it feels a little much, as if the authors don't give enough respect to the reader's intelligence.

"Even if you're slow in the head this book is for you!" -Matt Curry, PseudoCoder.com

Much of the same materiel is covered in the example blog application in the CakePHP manual. The blog app doesn't have as much discussion as the todo app, but depending on your learning style this may be better. The code, to someone who is familiar with PHP at least, is fairly self explanatory for these types of beginner apps, so having a section of text, just as long as the code, really isn't necessary. It's like when you see a comment "//increment $i" and the next line is "$i ++". Really the comment isn't necessary. There are many good parts to the authors explanations, but at times these points can get lost in the filler text.

The Middle

You know the programming books that you always have near by - the ones that are a deep and valuable reference? CakePHP Application Development isn't like that. This becomes clear in the second major app built in the book: a book catalog system. In this part of the book two of the more important concepts are introduced: validation and model relationships. Take the validation section for example. It does a nice job of describing the format of the validation array, the various keys and one basic custom validation routine. But if you want to know more about a particular validation rule or even a full list of the rules it directs you towards book.cakephp.org. If you buy the book thinking of it as an extended tutorial you won't be disappointed. If you're looking for a handy reference stick with the online manual.

"The $39.99 price tag may seem a bit high, but once you factor in that you'll never need the book after reading it and can re-sell it on eBay it becomes a bargain." -Matt Curry, PseudoCoder.com

The End

The last app made in the book is called "Quickwall" and is a questions/answers app. This app brings together all the pieces you've learned so far and then goes over some of the splashier extras, like AJAX, RSS, and Pagination. I think the RSS section is a good example of one of my issues with the book. Many of the concepts explained in the book teach the reader how to do something within the example app, rather then teaching the user about the feature in general so that they can apply it to any app. The "What Just Happened" sections that follow most of the code examples tries to remedy that, but some of the value is lost by having long block of code followed by long blocks of text, rather then intermingling the two.

Random Rant

I think my biggest gripe with CakePHP is the name. Well, not the name itself, but the fact that the name leads to excessively trite cooking analogies. This book is no exception. Some examples:

  • "The ingredients are fresh, sliced up, and in place. The oven is switched on, heated and burning red. It is time for us to put on the cooking had, and start making some delicious cake recipes."
  • "...and making a quality application with CakePHP is as easy as easting a cake."
  • "Keep reading, and you will become an expert baker in no time!"
  • "Scaffolding is great for quick templates, but eventually you're going to have to add your own secret ingredients. Like the human flesh I use in my decadent chocolate fudge cake."

Fine, I made that last one up. But you get the point. I assume all the other framework have this same issue. symfony coders are probably called "conductors" and programming is probably called "composing". Code Igniters probably go by "arsonists" and coding is "burning that fucker down."

Not That Bad

In general I don't think the book is that bad. I remember some very frustrating days when I was first learning CakePHP and having this book then probably would have helped me out. As someone first learning CakePHP I'd probably check out the online/free blog tutorial first and if I felt I needed a more in depth tutorial I'd get this book.

"Not that bad." -Matt Curry, PseudoCoder.com

Posted in CakePHP | 6 Comments

.8 Reasons to hate CakePHP

Posted by Matt on Tue, Dec 23 2008

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).

Posted in CakePHP | 22 Comments
1 | 2 | 3 | 4 | 5