CakePHP, Set "cake" Environment Variable?

Sam picture Sam · Feb 15, 2010 · Viewed 8.2k times · Source

I'm using the "cake" console in cakephp on Mac OS X 10.6.2. How do I set up the environment variable (or PATH?) so that all I need to type in terminal is "cake"... as opposed to the full path to the console app?

I'm unabashedly a newb when it comes to terminal commands and these UNIX things (but I'm learning!), so bear with me if my explanation/vocabulary is a bit off.

Answer

matiasf picture matiasf · Feb 15, 2010

You should add

alias cake=PATH_TO_CAKE

To your .bashrc file (it's usually in your home directory).

To expose all cake scripts in the shell directory, add the cake shell path to your system path.

export PATH=/your_path_to_cake:$PATH

Both alias and export can be added to your .bashrc file or executed directly on the command line. .bashrc is a shell script which will be executed each time you start a new shell session and placing one or both of the lines will make cake point to the correct program reagardless of your working directory.