Configure CakePHP Console in Linux

CakePHP is a rapidly evolving, MVC, framework for PHP.  Many websites these days are being developed using it and there is a demand amongst developers to learn and use it.  Although CakePHP is very easy to download, extract and start developing, there is a seldom used command called the CakePHP Console that can be used to speed up development time significantly.  CakePHP Console can do much of the code writing for you such as creating the CakePHP folder structure, creating models, controllers and views, database configuration, data validation and scaffolding, just to name a few.

Using the CakePHP Console can be done by referencing the “cake” console command by accessing it by its relative location in the file system (../cake/console/cake) or you can add the “cake” console command path to your Linux $PATH environment variable.

The only advantage that comes to mind with adding the “cake” console command to the $PATH environment variable is that it reduces the number of duplicate files if you are running multiple web applications using the CakePHP framework.  Also it avoid the tedious task of constantly referencing the full “cake” console command every time it needs to be used.

This is what I will be showing you how to do in this tutorial.

Step 1: Download the latest stable version on CakePHP (currently version 1.3.3)

# wget http://github.com/cakephp/cakephp/tarball/1.3.3

Step 2: Extract downloaded file

# tar xvfz cakephp-cakephp-1.3.3-0-gf01b4ae.tar.gz

Step 3: Rename folder to “cakephp”

# mv cakephp-cakephp-efb6e08/ cakephp

Step 4: This step is optional. Move the “cakephp” folder to a location of your choice (in my case I moved it to /usr/src – need root access to move folder to this location)

# mv cakephp /usr/src/

Step 5: This step is done based on the level of access you have on the linux server you are working with, but it either case you will need to append the following to the approriate file.

PATH=$PATH:/path-to-cake-console-directory
export PATH

Edit the following file if you only have access to edit the environment variable for your own user account: /home/username/.bash_profile

Edit the following file if you have access to edit the environment variable for all user accounts (except root): /etc/profile

Edit the following file if you have access to edit the environment variable for the root user account: /root/.bash_profile

example from my configuration:
PATH=$PATH:/usr/src/cakephp/cake/console
export PATH

You will need to logout and log back in for the changes to take effect. I hope this article helps. Please leave your comments

3 Responses to “Configure CakePHP Console in Linux”

  1. pharmacy tech said:

    Aug 23, 10 at 1:39 PM

    Great site. A lot of useful information here. I’m sending it to some friends!

  2. Wordpress Themes said:

    Sep 24, 10 at 6:00 PM

    Nice post and this enter helped me alot in my college assignement. Thanks you on your information.

  3. driss said:

    Jul 07, 11 at 6:30 AM

    great informations man thanks


Leave a Reply