Yii 1.1: How to setup yiic on WAMP (XP/Vista)


This page assumes that you have installed Wampserver on your MS Windows computer.

Start with downloading Yii and deploy the framework in your webroot/vhost (C:\wamp\www\).

Open the Environment Variables window by going to: Start -> My Computer (right click!) -> Advanced Tab -> Environment Variables -> Click Path in System variables -> Edit.

In Windows 7, press the Win key and type "env". You should see a control panel section with a shortcut to "Edit the system environment variables". Select it and then click on "Environment Variables...".

Click on the variable called PATH and click "Edit...". Do not delete the paths already there! Separate each path with semicolons.

Now you have to add the following PATHs in Windows: "C:\wamp\bin\php\php5.2.8" and "C:\wamp\www\framework". The former path should lead where your php.exe resides, and the latter where your yiic.bat resides.

After entering the paths, type cmd in your startmenus searchfield, and go to the webroot. You may have to restart the computer if this does not work for you so that Windows can register the new variables.

yiic webapp mywebsite

Will generate a Yii skeleton for your web application inside the directory "mywebsite" in your WAMP webroot folder. One reason that you should stand in your WAMP webroot when giving the yiic commands is that you don't have to specify where you want the web application generated.

Accessing yiic for the local web applicaton ΒΆ

After you have created your webapp you want to use the yiic command shell to generate model classes and using the CRUD functionality.

For this you should go to "C:\wamp\www\mywebsite\protected". The reason you should stand here is that you want to use the local yiic command for the application. This is necessary if you want to create models and CRUD using the database schema as a template. The yiic command will use the configuration of the web application!

yiic shell ..\index.php

This command will start the local yiic shell that gives you access to the CRUD commands and even the commands that you build into your webapp.

Don't forget to configure your database settings in protected\config\console.php.

Total 3 comments

#11405 report it
hackerunet at 2013/01/11 09:46am
Easy fix to yiic shell access

Please, just type in the execute command window in Window menu: environment variables > open up the environment variables editor > click on environment variables under the Advanced tap add new variable, in "Variable Name" type "Path" and in the value type in "c:\path\to\php;c:\path\to\php\php.exe" without the quotes. Restart and that's all !! now your yiic knows where php.exe is.

#9585 report it
logos010 at 2012/08/25 09:49am
Setup Yii in xampp server

After open comment line, just follow these steps: Step 1: "D:" - If your xampp server was installed default in C:, skip this steps Step 2: "cd xampp\php" - Access to xampp\php folder where contain "php.exe" file. Step 3: "php.exe D:\xampp\htdocs\yii\yii-1.1.8.r3324\framework\yiic webapp D:\xampp\htdocs\projects\project_name" -call "php.exe" to excecute yiic and create a website application Step 4: "y" -Press Y/y to ensure your project install correctly. DONE! Hope help

#1138 report it
michaelc at 2009/11/30 03:59pm
fixing testdrive 'php.exe' is not recognized as an internal or external command, operable program or batch file.

Navigate to: \yii\framework\yiic.bat (ms dos batch file). Open with your preferred text editor.

change the line: if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe

to the following: if "%PHP_COMMAND%" == "" set PHP_COMMAND=c:\wamp\bin\php\php5.3.0\php.exe (or whatever the FULL path to your php.exe file is)

save and open the command prompt and enter the following:

cd c:\wamp\www\framework (this is my path... yours may be different. The action sets the directory you are operating out of as the "framework" directory)

then enter this:

c:\wamp\www\framework>c:\wamp\www\testing (or whatever path you would like to use)

This should fix the issue and you should see the following output:

The following commands are available: -message -shell -webapp

Good luck!

Leave a comment

Please to leave your comment.

Write new article
  • Written by: krillzip
  • Updated by: Yang He
  • Category: Tutorials
  • Yii Version: 1.1
  • Votes: +3 / -1
  • Viewed: 80,251 times
  • Created on: Feb 5, 2009
  • Last updated: Jun 29, 2012