Running CakePHP Command Line Tools in Windows
This tutorial will review how to set up the CakePHP 2.0.5 command line console for Windows 7 running WAMP, but the instructions should be similar for Windows Vista and XP as well. We will assume that you already have CakePHP installed, and that your database is configured correctly.
First, we need to set Environment Variables so that Windows can run cake from the command console:
- Open “Computer” under your Windows Start menu
- Right-click the “Computer” window, and select “Properties”
- You will be brought to the Control Panel’s System window. We’ll need to change our environment variables under “Advanced System Settings,” which you can select from the left column menu in this window
- Select the “Advanced” tab on the System Properties window
- Click the “Environment Variables…” button
- In the System Variables box, find the “Path” variable and click “Edit…”
- If there isn’t one already, add a semicolon to the end of the current “Path” variable (a semicolon is used to separate variables)
I use WAMP as my local development environment, and store all of my CakePHP projects in the C:\wamp\www directory, so my path variables will refer to this “wamp” directory. My CakePHP project also resides in a directory named “order_system.” Yours may differ depending on your development environment and where you have CakePHP installed, so be sure to change these directories to fit your needs
- At the end of your Path variable add
c:\wamp\bin\php\php5.3.8\;c:\wamp\www\order_system\app\Console\;
(The first path should point to your installation of PHP, and second variable should point to the “app\Console” location ofthe project that you are developing) - Click “OK” to save your changes.
Once the Path variables have been saved, we can run a test to be sure that the variables are pointing to the appropriate locations
- From the Windows Start menu, search for “Run”
- In the “Run” prompt, type “cmd.exe” to execute the Windows command line console
- Your command line console will likely be pointing to your User directory initially. Type “cake” at the prompt.
If your environment variables are correct, you should see a “Welcome to CakePHP Console” message, similar to:
CakePHP command console is working properly, but it will need to run within our CakePHP project. As you can see from the screenshot, our working path should be the same as our application path. In order to rectify this, simply use the Change Directory (cd) command to change the path to the “app” folder inside your CakePHP project:
cd c:\wamp\www\order_system\app
Now that we are in the correct directory, we can instruct CakePHP to “bake” our project, simply by typing at the prompt:
cake bake
Alternatively, you can skip the bake menu, and jump right into baking a controller, project, view, etc. by running any of these commands at the command line:
cake bake db_config cake bake model cake bake view cake bake controller cake bake project cake bake fixture cake bake test cake bake plugin plugin_name cake bake all
For example, instead of entering “cake bake” after changing to your project directory, enter
cake bake controller
Refer:
http://www.nurelm.com/themanual/2012/01/30/running-cakephp-command-line-tools-in-windows/
0 comments:
Post a Comment