Getting Started With CakePHP

Here’s a couple of things I did wrong when trying to use CakePHP, for your benefit.

Several months ago I applied at a company called Radar Hill, which uses Cake as their main framework. Naturally I set about learning how to use it as soon as possible. I didn’t do very well. I it on Rocketships, but couldn’t figure out how to make it run – there were a variety of problems that I’m not quite experienced enough to recognize.

Then I tried it locally on my MacBook. I made progress, but the database part stumped me until I found out about MAMP, which got me a little further. But it still wasn’t what you’d call a success. Finally, the job interview at Radar Hill rolled around, and I was not hired, mainly because of my inexperience with PHP. Sigh. I tried!

However, the guys who interviewed me were very encouraging, and said to keep trying and stay in touch. One, Jamie, gave me some tips on how to run it on the Mac. His instructions worked perfectly.

 

First Mistake

.htaccess files sometimes don’t copy and paste in the Mac finder, because the . at the beginning of the file name renders them invisible (except when it doesn’t).

The solution was found here:

Probably the hardest to do but uses the least amount of work and has the most potential to go wrong, that is the Terminal Method. If you open up terminal (Applications > Utilities) and type the following:

 

defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder

 

This will show you all of the hidden files and folders on your operating system. If you want to reverse the command replace TRUE with FALSE.

Then check the Cake files to make sure that all 3 .htaccess files are present – as detailed by this very helpful post on Stack Overflow. There should be one at the top level of your cake directory, one in /app, and one in /app/webroot.

Second Mistake

I was putting files in all sort of random places, trying to find a way that worked. Jamie said to unzip the Cake download into /MAMP/htdocs, replacing anything else in that directory. This is probably a dumb newb mistake, but I’m sure at least one other person has made it.

What Jamie Said

#1: Download and install MAMP:

It’s an “out-of-the-box” LAMP environment for the Mac. It’s all I ever use.

#2: Start MAMP, and then go to the homepage, which by default is:

#3: Click on the “phpMyAdmin” tab at the top. You can also get there
directly:

Create a new database and call it whatever you want – something descriptive.

#4: Download the latest version of CakePHP 2.2, currently RC1, from here:

#5: Extract the archive and put its contents into
/Applications/MAMP/htdocs (replace whatever’s there).

Open the database config file for editing, which is at (relative to htdocs):

app/Config/database.php.default

#6: In the DATABASE_CONFIG class in the file you’ll see this array,
which is the default DB config:

Change it to this:

#7: IMPORTANTLY: don’t forget to replace “your_database_name” above with
the actual name of the DB that you created.

#8: save that file as database.php, rather than database.php.default

#9: Browse to: http://localhost:8888/

If all went well you should see the ‘vanilla’ Cake installation.

– Jamie

 

 

 

Published by

Shannon Graham

Shannon has been writing brief essays and occasional how-to articles at Rocketships, Unaffiliated (.ca) whenever inspiration strikes, since 2012. She is interested in your opinion.

2 thoughts on “Getting Started With CakePHP”

  1. This is actually quite helpful. I’m coming from RoR so I feel like a n00b most of the time, too. Don’t worry, it’ll go away in a few years. But, then you’ll feel like a n00b about something else 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *