A Cake 2.x warning: Skip those next sections and read the bottom part (“Hot Tip”) – and do NOT add Cake to the system path anymore.
Windows and CakePHP 1.x
Nothing easier than that! 2 minutes and it works.
I prefer WAMP (XAMPP sucks). But I describe it for both. WAMP has the advantage that you can easily switch php versions (5.2.10, 5.3.0, 5.3.1, …). For the path it is annoying to edit the version number all the time. So (WAMP ONLY!) copy your desired php version from /bin/php/php5.x.x to /bin/php/php_for_console. If you now need to switch the php version you can simply replace the files in this folder. You don’t have to edit the system path. For XAMPP there is usually only one php directory, anyway.
We need to add these two paths to the System Path: C:...\xampp\php; (for XAMPP) OR C:...\wamp\bin\php\php_for_console (for WAMP with copied folder) OR C:...\wamp\bin\php\php5.x.x (for WAMP without the above trick – not recommended)
AND C:...\project\cake\console (your project is usually inside www or htdocs folder)
Here you could set up a second cake folder, as well, which only serves the console (e.g. “C:...\wamp\bin\cake”). This way the CakePHP version for the console can easily be managed – separately from any CakePHP app.
We need to open “my pc properties” -> “environment variables”. In “path” we need to append the 2 paths from above.
Separate them with semicolons:
Done! It should now work right away on any Windows (XP, Vista, 7). Not sure if a restart is necessary, though.
Please note: If you have multiple partitions, don’t put your cake/php stuff (WAMP, XAMPP) on C:. There might be some user rights issues. You are better off using D:/ or any other partition. And you shouldn’t have any persistent data on the system partition, anyway. I usually have windows and installed programs one C:\, everything else is on other partitions.
Don’t just open a console. In order to use the console for any of your apps you need to navigate to the APP folder. Otherwise “cake …” etc will not find the shell scripts in your app:
Hot Tip: To quickly open a cake console on any of your apps, simply press SHIFT + right click on the app folder. You will now see a new button “Open console here” / “Eingabeaufforderung hier öffnen”. That’s it. With “cake” you should see the welcome screen and a list of all possible shells.
And – if you did everything right – you should be able to execute your shells like so:
cake command args -params
For example to bake a model:
cake bake model
NEW – Cake2.x
For Cake2 we need to adjust the project path like so:
Nothing fancy after all.
If you need to run both 1.x and 2.x on the same system (or multiple cake apps/cores on the same system for that matter), don’t append anything besides the pure PHP path to the System path. You can then create two keyboard shortcuts (like I did) for the different versions with a tool of your choice.
cw1# (“cake windows v1)” for
So I am in the app path and just type
cw# bake which automatically translates
cw# into the above path and then, of course, starts up the bake shell.
..\ syntax CLI always uses the correct CakePHP version (in /trunk/lib if your project app is in /trunk/app).
Note: On 2.x you usually also have an APP
Console/ folder which you can leverage as a shortcut:
Console/cakethen suffices for unix
So in short: DO NOT add the cake path to the system environment path.