My talk on CakePHP went pretty well, though it did come to my attention after talking to a few folks afterwards that there were those in the room who need more help getting a start in server-side coding rather than getting a primer on a great framework for PHP. There is a wide range of people who come to Refresh Pittsburgh — designers and developers who have passions for front-end hacking like HTML, CSS and JavaScript. My talk didn’t focus on getting the attention of those folks, so if I made you yawn I apologize!

I’ll refrain from posting my (admittedly lacking) Keynote presentation, because there are simply better resources out there for learning and understanding CakePHP and the concepts behind it. Currently, Tempdocs is a great place to start. Skip to the bottom of this post for a more comprehensive list.

For people looking to brush up on some basic PHP and MySQL before diving into Cake, here’s some great articles I’ve found:

PHP and MySQL

Before you start, you’ll need to get PHP and MySQL working on your computer. I highly recommend these all-in-one packages: MAMP (Mac) or XAMPP (Windows). These packages come with Apache, PHP, MySQL, and some common tools like phpMyAdmin, a web-based MySQL administration tool.

Cakeblog

Cakeblog is my (very bare and incomplete) blog application written in PHP using Cake. I used it to reference actual code in the talk. It’s open-source, so I encourage everyone to download it, modify it, and customize it for yourself. Sometimes you just need an excuse to get started.

Here’s some basic instructions to get you off the ground:

  1. First you need to get PHP and MySQL working on your computer. Again, I highly recommend MAMP (Mac) or XAMPP (Windows) for all-in-one solutions.
  2. Get Subversion (SVN).
    • For Mac OS X, download Martin Ott’s install package and run it. If you want a GUI interface for working with SVN, I recommend svnX.
    • For Windows, I recommend TortoiseSVN, which integrates with Windows pretty nicely.
  3. Download your own copy of Cakeblog at Google Code using SVN. After you’re done, you should see folders called “app”, “cake”, “docs” and “vendors” along with files called “.htaccess” and “index.php”. This is the basic folder structure.
  4. Point your MAMP, XAMPP or home-baked web server to the folder you downloaded Cakeblog to. Restart the web server. Now if you go to “http://localhost” in your web browser. You should see some errors. This is because we don’t have a database yet!
  5. Now, open up phpMyAdmin (should be “http://localhost/phpMyAdmin” or “http://localhost/phpmyadmin”), log in (root/root I think is the default username/password for MAMP. YMMV.), and create a database called “blog” on the main screen when you log in. (For added brownie points, select “utf8_general_ci” as the collation for the database.)
  6. Make sure you’re now currently viewing the new empty “blog” database. Click the “Import” tab. Browse for the SQL file called “blog.sql” in the “app/config/sql” folder and select it. Once you have, click “Go” at the bottom of the Import screen. Everything should import successfully.
  7. Check out “http://localhost” in your web browser again. You should see the main front-end screen with a few blog posts. You got it working!
  8. To log-in to the administrative back-end, go to “http://localhost/admin” or click the “admin” link in the top-right-hand corner and use “test” for the username and “test” for the password (both without quotes). Now you should be logged in.

Let me know if you have any questions by leaving a comment on this post!

CakePHP Resources

Here’s some links I’ve used to understand the concepts behind CakePHP.

Summary

I’m confident once you start realizing the potential of using CakePHP as a platform for your PHP web applications, you won’t look back. Take some of the resources I’ve provided and run with them. You may be surprised how much you learn.

3 Responses to “CakePHP: Rapid Application Development with PHP”

  1. Gravatar

    One of these days, I’ll make it to Refresh Pittsburgh. Perhaps when I’m actually in.. Pittsburgh!

    I’d love to hear about CakePHP and how one would make a switch from Rails.

  2. Gravatar

    nothing against coobooks and agile, rapid etc. development. but i talked recently to a friend who run a travel site in europe and they have an excellent programmer who decided for some reason to develop the site in some now almost extinct programming language.

    people should not forget that PHP and python at least are so widespread that you are not in danger to find it incredibly hard to find a capable programmer and have a maintained code source which is developed furher.

    if we would jump on every band wagon i guess the world would be RoR only these days :-)

  3. Gravatar

    @dimitry: I really encourage you to check out Cakeblog. It’s a really bare-bones version of a Cake app I wrote for the presentation. Check out the link and the instructions above for how to get started. Once you look through it I think you’ll find it very similar to Rails in a lot of ways.

    @jens: I definitely agree. I know excellent programmers who don’t use frameworks at all. It’s all about using the right tool for the job. PHP is nice because it’s widely supported — mostly because it’s widely recognized as the web language of choice for people who are just learning or are trying to bootstrap basic web apps.

Leave a Reply