Sharpening the Blades: Document Ready, Admins and Automagic in CakePHP

01.19.2010   |   0comment

This edition of Sharpening the Blades features articles about creating admin sections with CakePHP,  how $(document).ready( ) can slow down your site, and the wonderful things CakePHP can do “automagically.” Hopefully these articles will help you sharpen your coding blades.

Chad, Creating an Admin Section with CakePHPcakephp-admin
I have come across James blog just recently (about 2 months). The guys blog is great. He does so much with CakePHP that it is great to see what he is doing and what he can do. But the reason I suggest this specific post is because it seems to be the first stumbling block that every developer comes across while using CakePHP. This article specifically will explain how to get an Admin section set up and working. I consider this one of the must needed to know things to develop correctly in CakePHP.

Benjam, Don’t let Document Ready slow you downdocument-ready
Everybody wants to have a faster loading website, and I am certainly guilty of putting every DOM related jQuery snippet into the $(document).ready( ) function.  This post showed me that this wasn’t absolutely necessary and gives good examples of when and how to break out of the document ready mentality.

Mac, The Dark Side of CakePHP’s Automagicautomagic-cakephp
I’m not sure I like the title of this article so much as I like the article itself, but it does point out some useful information about the “automagic” things that CakePHP does for you. Some of the things they discuss are definitely features that were designed very wisely, even though the article seems to disagree with me on that. There are definitely some automagic things in Cake that they mention that drive me crazy too though, and I don’t really see the necessity for the seemingly poor decision made by Cake’s developers. My biggest peeve they mention are the behavior it has (or had, this may have been fixed/changed now) for many-to-many relationships (a.k.a. HABTM). It is really a pain in the neck when your relationship table has other data in it, like the date/time when the relationship was added, or by whom, or a quantity, etc.


Whirly Bin

Luke,on the topic of  CakePHP, Web Development
10.29.2009   |   0comment

We recently launched a small ecommerce site for Whirly Bin. They sell all sorts of stationary. They needed a super simple shopping cart. Instead of hooking in our custom cart in CakePHP we hooked it up to PayPal. Whirly Bin can add new products and upload photos and descriptions for those products through a simple admin section we created with CakePHP. Whilry Bin was great to work with and we got the site designed, built, and up really quick. Check out their site.


“What does that do?” - Cake functions I’ve found

Benjam,on the topic of  CakePHP, PHP
05.07.2009   |   0comment

In this episode of “What does that do?” we’re going to look at a few helpers and methods of (probably) well known classes that may or may not be that well known, as well as enlighten you to a few gotchas that I’ve discovered during my Cake usage.

First is the Set::extract method. When I first started using Cake, I was using the dot notation in my extract and combine calls, that is until I discovered the XPath notation that was also allowed which offers more control over your returned values. One gotcha that I discovered early on, was that to emulate the dot notation {n}.Foo, you can’t just use /Foo, you have to add a /. to the end to make it work properly. So you end up with /Foo/.. One other thing I noticed while poking around in the source, was that the argument order for extract is opposite from that of combine. With combine, you put $data, then $path[12]. With extract, you put in $path first, then $data. I was doing it wrong for a long time, but the Cake developers thought of this, and silently flip them in extract if you get them backwards.

(more…)


Why we use CakePHP

Benjam,on the topic of  CakePHP
02.26.2009   |   15comment

Cake LogoWhen I first started working at Code Greene, I was building my PHP applications and sites the “old fashioned” way, with nothing more than a collection of common functions and a single MySQL class that I carried around with me everywhere. I have grown very accustomed to my small collection of code, and have begun to rely on it a bit (and actually almost failed the entrance test to Code Greene because I couldn’t find it).  But I always built my applications from scratch, every time. 

As I progressed in my PHP career (and hobbies), I noticed that I was building the same things over and over again, but only slightly different every time.  This was an issue that I had noticed but never really put some serious thought into… until I started at Code Greene.  My first day there, I was told to take a look at CakePHP and learn it, because it was to be the defacto PHP framework for the office.  I took a quick glance at the code base and was instantly overwhelmed.  There is so much stuff going on behind the scenes in Cake that it boggles the mind a bit.  I went through a few online tutorials, and still felt that I knew nothing about it, let alone how to use it, but I could tell that it would either make or break my new job.
(more…)