CakePHP: Calling bake from every dev-app install folder

If you use a setup like I explained in my previous post calling the bake script involves a lot of typing with the core and app parameter paths.

If I want to call the bake script from the /Users/mwesten/Sites/dev/myapp cake app folder, it has to be done like this:

php /Users/mwesten/Sites/cake1.2.x.x/cake/scripts/bake.php -core /Users/mwesten/Sites/cake1.2.x.x/cake  -app /Users/mwesten/Sites/dev/myapp

To make things easier on myself I use the following alias and shell script. First I edit /etc/profile (or ~/.bash_profile)

sudo mate -w /etc/profile

and add the following line:

alias bake="/Users/mwesten/cake12bake.sh"

After this I create the shell script:

mate /Users/mwesten/cake12bake.sh

add the following 2 lines:

#!/bin/sh
php /Users/mwesten/Sites/cake1.2.x.x/cake/scripts/bake.php -core /Users/mwesten/Sites/cake1.2.x.x/cake -app $PWD

Now you can execute the bake script from the app folders.

UPDATE: If you are using the latest version (bleeding edge dev install of CakePHP 1.2) you can do the following instead: edit /etc/profile or ~/.bash_profile and add the following folder to the path statement: /Users/mwesten/Sites/cake1.2.x.x/cake/console

After this you can call the bake script like this:

cake bake

or just "cake" for all possible options….

Hmmm….. For some reason it now still calls the wrong app folder, but I think it will be fixed in no-time ;)