09 Sep 2009

CakePHP Baking Console with XAMPP on OS X

CakePHP, PHP, Tutorials posted by Brandon Showers

I am going to quickly show you how to setup your CakePHP Baking Console on XAMPP for OS X. Ok lets jump right in.

Download the latest version of CakePHP

If you have not already done so please download the latest version of CakePHP. Now that you have downloaded Cake, unzip and place it into your htdocs folder on your XAMPP setup. I would suggest changing the folder name to something a little more friendly but of course this is up to you.

Baking Console and PHP5 bin file paths

Now that we have installed cake we need to locate the absolute file paths for the cake console and the php5 lib file. Take a note of these two paths. We will need them later.

The absolute path to the Cake Console folder will look like this.

/Applications/xampp/xamppfiles/htdocs/YOUR-CAKE-FOLDER/cake/console

The absolute path to the PHP5 bin file will look like this.

/Applications/xampp/xamppfiles/bin

Setup .profile file

Open up terminal. Make sure that you are in your home directory (/Users/YOUR-USERNAME) by typing

$ pwd

If you are not in your home directory, this will take you there:

$ cd ~

Now that we are in our home directory we need to edit the .profile file:

$ nano .profile

This will begin editing the .profile file. You may not have this file in your home directory so doing this will create a new one.

Now this is where we will use the file paths that we have noted in the previous “Baking Console and PHP5 bin file paths” step. Add this line to your .profile file changing PATH-TO-BIN-PHP5 to the absolute path the PHP5 bin file and PATH-TO-CAKE-BAKE-CONSOLE to the absolute path for the backing console:

$ export PATH="PATH-TO-BIN-PHP5:PATH-TO-CAKE-BAKE-CONSOLE:$PATH"

It will look something like this:

$ export PATH="/Applications/xampp/xamppfiles/bin :
/Applications/xampp/xamppfiles/htdocs/cake/cake/console :
$PATH"

REMOVE THE SPACES BETWEEN THE COLONS. THIS SHOULD ALL BE ON ONE LINE. Now save and exit the file

Reload the .profile file:

$ . .profile

Testing the baking console

After you have reloaded the .profile file you should test the Cake Console to make sure you have configured everything correctly. Change your directory to your webroot or htdocs folder and try

$ cake bake mytestapp

If everything is configured correctly your terminal window will display the following screen beginning the baking process.

CakePHP Cake Console

Congratulations and Happy Baking!

Leave a Reply