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.
Links
Total 18 comments:
Hi everybody,
I don't know about Vista (and I never will ...) but with XP after right clicking on "My computer" you first have to choose "Properties" and then do all the things stated above.
Other than that: thanks for the recipe!
Works like a charm.
When it didn't recognized the yiic command, i cd'd to my localhost dir (webroot)
I am getting this message:
"'php.exe' not recognized as an internal or external command, operable or batch file"
But I am new to this and it is possible that I do not know what I am doing.
In the System Variables, what am I supposed to name them?
I named the first one 'yiic' and the second one 'php'.
Can't seem to get anything working though.
Help would be appreciated.
Peace
@backgammon...
open "yiic.bat" in your applications directory via notepad or any text editor you like.
change: if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
to: if "%PHP_COMMAND%" == "" set PHP_COMMAND=php-cgi.exe
@mrlami -
thanks for the tip -
will give it a shot tomorrow and report back to mission control
Peace
I am getting the same error when I make that change:
"'php-cgi.exe' not recognized as an internal or external command, operable or batch file"
any other suggestions?
what exactly would be the cause of this issue?
i got it figured out -
lookin cool but this summary here is not quite friendly for folks that have never worked with environment variables before
if i get some time i will try and post up something a bit more thorough and candy-coated for us beginner-types
thanks for the help
Peace
I made the changes above (in Vista), and go to the protected directory in the testdrive app and invoke the command above (after having changed php.exe to php-cgi.exe in the bat file), and get:
This script must be run from the command line
I had to use full path for the php.exe i.e if "%PHP_COMMAND%" == "" set PHP_COMMAND=F:/Programmid/wamp/bin/php/php5.2.8/php.exe
It was because I reinstalled windows or sth, not really yiic fault.
A little offtopic, but if using tasksel lamp in linux, this was also required to run: sudo apt-get install php5-cli
i got a problem on executing yiic webapp testdrive on my command line it shows this responce
C:\xampp\htdocs\yii\framework>yiic webapp testdrive 'php.exe' is not recognized as an internal or external command, operable program or batch file.
hmmm what do think guys is the best solution?? im running a windows vista
got the solution guys... sandwich is correct
one last question if im going to edit the path at system variable... what would be the value of PATH? im not familiar on that setting.... and im afraid to change because lately when i try to change it configuring PHP it affects the JRE and my Eclipse IDE start not Launching
Just open the Path variable and set:
.....all_things_already_existing;C:\wamp\www\framework;C:\wamp\bin\php\phpxxx;Whatever_you_want;
You don't need to replace anything in your Path, just add the paths by separating them with a ;
So, path1;path2;path3;...
regards
I cant work it out. Iam using windows 7. Ive got set all variables for PHP and for framework. Yii is instaled into htmldocs folder and requirements are all fine. When i run command in htmldocs root "yiic webapp testdrive" nothing happen... no errors nothing... I also tried this command from framework folder "d:/dev/www/yii/framework webapp ../../testdrive" with same result... Iam running several webpages on my localhost so php is working fine... Any ideas ? What Iam doing wrong ?
Is the last notice (not to forget database config in console.php) still up to date? Because in my environment, yiic seems to use the web applications main.php config file. Database connection gets established without having to touch console.php
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!
Same problem as pjoter. Windows 7. Paths set properly. Requirements pass. When I issue the yiic webapp command, nothing happens. No errors. No webapp. Nothing.
I've configured web applications on windows and linux machines for over 12 years in php, perl, java and rails. If I can't figure it out, there's probably a bug in the script.

I can confirm the above also works on XP, guys. :)