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

Chinese version

Total 18 comments:

#69
Works also on XP
by cass at 2:35pm on February 9, 2009.

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

#74
Setting PATH -- intermediate step
by chessplayer at 2:47am on February 11, 2009.

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!

#133
Also works under Vista with XAMPP
by beatniak at 3:44am on March 24, 2009.

Works like a charm.

When it didn't recognized the yiic command, i cd'd to my localhost dir (webroot)

#142
Can't seem to get this to work on Vista
by backgammon at 3:54pm on March 25, 2009.

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

#144
This might help
by mrlami at 3:07pm on March 26, 2009.

@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

#145
i will give it a shot
by backgammon at 3:36pm on March 26, 2009.

@mrlami -

thanks for the tip -

will give it a shot tomorrow and report back to mission control

Peace

#150
no luck with that
by backgammon at 3:52pm on March 29, 2009.

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?

#151
a HA
by backgammon at 3:21am on March 30, 2009.

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

#185
Can't get the CRUD operations to run on Vista with WAMP
by ayendesigns at 4:03pm on April 9, 2009.

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

#216
full path
by sandwich at 4:28pm on April 21, 2009.

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.

#219
lamp
by sandwich at 4:47pm on April 22, 2009.

A little offtopic, but if using tasksel lamp in linux, this was also required to run: sudo apt-get install php5-cli

#273
error on C:\xampp\htdocs\yii\framework>yiic webapp testdrive
by esthony at 5:30am on May 9, 2009.

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

#274
simple solution
by esthony at 5:17am on May 9, 2009.

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

#379
It's quite easy
by scoob.junior at 6:59am on June 12, 2009.

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

#591
cant create new webapp
by pjoter at 8:02am on August 17, 2009.

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 ?

#658
database configuration
by Ben at 9:51am on September 14, 2009.

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

#842
fixing testdrive 'php.exe' is not recognized as an internal or external command, operable program or batch file.
by thrive at 11:59pm on November 30, 2009.

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!

#1250
can't create new webapp either
by paulrpayne at 3:13pm on March 9, 2010.

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.

Your Comment:

You may enter comment using Markdown syntax.

Please login with your forum account.
Note: you must have at least ONE forum post with your account.