Running CakePHP Command Line Tools in Windows
As a newbie to command line tools, I found myself overwhelmed while attempting to configure CakePHP’s command line console within a Windows 7 environment. Most of the tutorials that I found either referred to an older version of Windows, or a previous version of CakePHP. To developers new to command line or CakePHP, running the command line console may seem like a daunting task, but it is actually quite simple.
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)
- 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.
- 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.
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\appNow 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 allFor example, instead of entering “cake bake” after changing to your project directory, enter
cake bake controllerHappy Windows baking!
No comments:
Post a Comment