zen of coding

12-step program to get addicted to CakePHP

Yep, this one works in reverse of the other “popular, so-many-steps” programs.

Step 1. – Unlearn your old habits

Whether or not you have great habits, familiarity with many other frameworks, or no experience at all… it will still be of great benefit to open your mind and just try and learn the cake-way. You might disagree, you might dislike, but if you want to harness the power of CakePHP, drop your prior knowledge for just a second and try to understand why things are done the way they have been. After that, you might agree or like or even start getting a little addicted to the new paradigms and new opportunities that will become available to you as a developer.

“It’s a lot easier to create a masterpiece on a blank canvas, than it is to paint over someone else’s mess.”

Step 2. – Help out with the docs

Time and time again I’ve heard that CakePHP documentation “sucks”. Personally, I think it couldn’t be further from the truth (but let’s stay on topic). The new manual (AKA “The Book” or “Cookbook” http://book.cakephp.org) has become better than ever. Most importantly, it is a community-driven effort. Any part of the book can be edited and you are very welcome to improve the documentation in any way. Whether fixing a spelling mistake, providing a code sample or clarifying something in the explanation, everything counts and everything is important to your ultimate addiction to the framework. In other words, if you find something lacking you have the power to make it better.

Step 3. – Join the mailing list (google group)

CakePHP has a pretty large, active and helpful community: http://groups.google.com/group/cake-php. Join it, post any questions if you get stuck or try to give advice to someone else. By participating, you are not only helping out others (which is a good feeling, if nothing else), but also get to learn a little from reading and possibly solving other people’s dilemmas.

Step 4. – Jump onto the friendly IRC channel

To top things off CakePHP has a great, active IRC channel, which is excellent if you need some real-time support. Not only is the channel friendly and helpful, but it can also be quite entertaining at times and certainly can be used as a great learning tool to further increase your addiction.

Step 5. – Start coding, already

All the reading and preparation should not be discouraged, but the most important part is to just sit down and start coding. Even if you simply follow the blog tutorial. Even, if you are not sure if the approach you are taking is the best one. Code is constantly evolving and refactoring is just a natural part of a developer’s life. The sooner you get started the sooner you’ll be addicted. Of course it goes without saying, that nothing good will come out of your baking, unless you really get your hands in the dough.

Step 6. – Become best friends with the API

At the time of this writing CakePHP has acquired a brand-new API (only a few days old), thanks to Mark Story and other contributors. Yes, there are a few glitches still, but it is an indispensable tool for any developer. It might be a little overwhelming at first, but you really need to take it easy and learn to love it. The API is the ultimate answer to many of your cake-baking questions. Though the road to understanding might be a little rocky at first, the eventual habit will be hard to kick.

Step 7. – Fall in love with test cases

Is there anything better than the CakePHP API for a developer?
Indeed, there are test cases. The core test cases (which is what I’m referring to), cover about ~90% of the framework code. They show you every little detail about how to use this or that method in CakePHP and after a rough time with Step 6, will give you a great boost in moving up the scale of addictiveness.

Step 8. – Submit an article to the Bakery

So now you’re almost there… you’ve probably hit a rough bottom once or twice, but got back out on top. This would be a prefect time to share your experience with the community.
Have you built in an awesome app that needs to be seen by the world? … share a case study.
Got a sweet, little helper that we could all benefit from? … write about it in an article.
Figured out a function to make your life just a little easier? … submit a code snippet.
The bakery is the ultimate hub for sharing your knowledge with others and learning a thing or two in the process while getting exposure… and further twisting your already addicted mind.

Step 9. – Follow the time-line

At this point you must have the latest and the greatest. Following CakePHP time-line is educational… and important, if you wish to stay on top of the world. http://code.cakephp.org/timeline gives you a perfect overview of what is happening on daily basis in the sad life of cake bakers. You’ll notice that there are almost daily code commits to the core, countless tickets being answered and closed due to a variety of “fun” reasons. But, more importantly, you see that this thing is alive and kicking.
It’s comforting to know that when you’ve gone through all the tough and rough steps, so far, you are not alone out there. Cake devs are working hard and tireless to ease your pains.

Step 10. – Write a test case and submit a patch

Can I imagine that you are a true cake-addict by now? Well, say what you wish, but nothing is perfect. If you see something you dislike or have a brilliant idea to optimize something in the core, then be a friend and submit a ticket with a patch and a test case. But, please, be sure to do it right! … “This thing is not working!” is not a helpful ticket to anyone.
Take your time, sit back, and think about how to get the patch and test case working so that your next great idea will be quickly addressed and implemented. After all, nobody likes to wait for the next dose of addiction.

Step 11. – Contribute

It doesn’t matter if you are a cake guru, an OOP master, or a PHP evangelist. Contribution to the project can come in many ways, shapes and forms. As mentioned before…. a little help with the docs, with related projects, with a clever Model Behavior, with a nice code snippet (a damn post on a blog, if all else fails)… is still a useful contribution. Everyone working on this and many related projects is a volunteer. Respect that, and become one as well. It will be a habit that’s hard to kick and in the long run it may actually (and surprisingly) play a very positive role in your own life.

Step 12. – Start dissing other frameworks

Yes, I’m joking around. Regardless of how far you get along in your life as a cakeaholic, it is always important to realize that no single tool is always right for any job. There are many great frameworks out there made by some nice and kind people to enhance your life as a developer. Obviously, I will encourage you to scream: “Cake is the BEST!” at every opportunity, but be respectful to those others, who are less fortunate.

P.S. New! This simple 12-step plan is provided completely free of charge, but you are welcome to send me two easy payments of $9.95 and one complicated payment of $12.35….

  • Absolutely spot on. Steps 1-6 should happen fairly quickly. Step 7 I highly recommend but I’ve found that unit-testing is a whole different monster and may take some time to learn how to write them effectively. Great read.

  • @Mike

    Thanks, I’m glad you’ve enjoyed it.

    #7 I meant more as a way to learn cake by looking at the core tests to see how certain methods are used, after you’ve got over step 6 :) That is, rather than doing your own unit testing, while developing… (which is still very important, of course).

  • Beth


    Is it mandatory to create a test case when reporting bugs?

  • @Beth

    In case you are proving a bug that’s in stable release and likely covered by a test in the core, the test is required in a vast majority of cases.

  • great list. although, IRC may not always be “friendly”. before IRC you should maybe put “Google It” because a lot of IRC advice will be snarky and send you back to googling things.

  • @dave rupert

    I guess it would depend on the question. IMO, (from spending about half my life on that channel) the amount of direct help people often get far outweighs the occasional “just google it” response.

  • Phally

    The great thing is, when you get the ‘Google it’ advise… It can actually be found with Google! ;)

  • @Phally

    LOL, very good point :)

  • Have only recently discovered your site. Great post, some tips I didn’t know about Cake and I just made an edit to the Cookbook because of it!

  • @Buck Muck

    Good to hear, and thanks for the contribution ;)

  • Pingback: 12 passos para se tornar um especialista em CakePHP « echo ‘mfandrade’ > /dev/net()

  • Pingback: 12 passos para se tornar um especialista em CakePHP « echo ‘mfandrade’ > /dev/net()

  • mfandrade

    Nice post! With your permission, I’d like to publish a translation to brazilian portuguese in my blog too.

  • @mfandrade

    Thanks, and you can definitely translate it.

  • Joy

    Very nice post. Enjoyed reading it.

  • @Joy

    Thanks, glad to hear ;)

  • Pingback: 12-step program to get addicted to CakePHP | Dailytuts.net - Daily tutorial for peoples()

  • Mitch H.

    We can’t tell you which payment it is, but one of these payments is going to be hard!

  • Fred

    Step 13 – despair at the performance of CachePHP for any site that isn’t either:

    1 – Tiny in traffic terms.
    2 – Prepared to spend far more on hardware than is necessary with many other frameworks and still end up with a slower site.

    And of course point 2 only works to a certain scale as Mozilla found out.

  • @Fred

    Interesting points… but what are they based on?

  • Hey thanks buddy for great post.

  • Best post posted by the author. & this post helped me a lot of.

%d bloggers like this: