views:

723

answers:

2

Here's a quickie that I assume has a simple answer (maybe? Hopefully?), but I just can't find one:

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.

Thanks in advance!

+3  A: 

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.

matiasf
Okay... except I can't find the .bashrc file. I've got a .bash_history file in there... but upon opening it, it's pretty clear that's not what I'm looking for. Any idea where the file is on Mac OS X 10.6?
Sam
Try creating it! Most Unix systems also provide a /etc/profiles to set shell defaults for all users.
matiasf
Yeah... sorry, that didn't do it. I created the .bashrc file and added:alias cake=/Applications/MAMP/cake/cake/console/cakeexport PATH=/Applications/MAMP/cake/cake/console/cake:$PATHSaved the file, logged out, logged back in, but no luck. There is a profile file in /etc... should I just add those 2 lines in there? Seeing as I don't really know what I'm doing, is this a good idea? You know, I think I'll do a quick back up before I try anything else!
Sam
A: 

The above solution posted by matiasf should get you going pretty quickly.

The only thing I'd recommend is putting your cake directory in a central location (ie, /usr/local/cake).

I recently wrote up some instructions in a blog post (http://developinginthedark.com/posts/cakephp-tip-2-run-multiple-cakephp-releases) that walks through settings things up on a Mac (and user commented instructions for Windows), specifically focusing on getting an environment up and running that supports multiple releases of CakePHP.

It sounds like you just need to get going with one version, but the instructions should still be relevant.

Hopefully this helps yourself and/or others.

Benjamin Pearson