I am currently experimenting with the Yii framework and I had some troubles running the yiic utility from Windows command prompt using the EasyPHP WAMP stack (I normally work on a Mac, but I wanted to make it work on Windows too).
While the stack works fine from a web browser, invoking PHP from its home directory under EasyPHP would raise a lot of warnings, mostly complaining about missing DLL extensions. Really annoying! It turns out php.exe cannot find its configuration file php.ini. Off to fix it.
1) There is a php.ini file in the php directory under EasyPHP installation directory, but this is not the right one. You need to use the one under EasyPHP\apache
instead. Rename the old one to something meaningful (just in case) and copy php.ini from EasyPHP\apache
into EasyPHP\php\php546x120925133033
where php546x120925133033 is the directory under EasyPHP\php
where php.exe can be found. Yours could be different, depending on your EasyPHP installation, and you need to use yours throughout the following steps.
2) When using yiic to generate a new web application, it typically needs to be launched from the web server root folder. yiic.bat is normally located into .\yii\framework
respect to the web server root folder and we need access to php.exe to make it run. Normally php.exe is not in the system PATH, so we need a way to access it.
The easiest solution I found is to edit yiic.bat to make sure it can find php.exe. Here is what the edited yiic.bat should look like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
@echo off rem ------------------------------------------------------------- rem Yii command line script for Windows. rem rem This is the bootstrap script for running yiic on Windows. rem rem @author Qiang Xue rem @link http://www.yiiframework.com/ rem @copyright Copyright © 2008 Yii Software LLC rem @license http://www.yiiframework.com/license/ rem @version $Id$ rem ------------------------------------------------------------- @setlocal set YII_PATH=C:\Program Files\Apps\EasyPHP-12.1\www\yii\framework\ if "%PHP_COMMAND%" == "" set PHP_COMMAND=C:\Program Files\Apps\EasyPHP-12.1\php\php546x120925133033\php.exe "%PHP_COMMAND%" "%YII_PATH%yiic" %* @endlocal |
Note that these 2 lines were modified to include php.exe into the system PATH (so it can be found) and to correctly reference the YII installation and the php.exe location.
set YII_PATH=C:\Program Files\Apps\EasyPHP-12.1\www\yii\framework\
if “%PHP_COMMAND%” == “” set PHP_COMMAND=C:\Program Files\Apps\EasyPHP-12.1\php\php546x120925133033\php.exe
Obviously you need to adapt your paths according to your EasyPHP and Yii installation. In my case EasyPHP was installed in C:\Program Files\Apps\EasyPHP-12.1
, with the web root called www
. Yii was installed in yii
inside EasyPHP the web root.
Once you are done with these settings, you can open a command prompt, navigate to EasyPHP web root (www
in my case) and use yiic with the following syntax (which will generate a new web application named myapp):
1 |
.\yii\framework\yiic webapp myapp |
If you want to invoke yiic.php directly through php.exe, you can think of adding the path to php.exe to the system PATH:
1 |
set PATH=%PATH%;C:\Program Files\Apps\EasyPHP-12.1\php\php546x120925133033\ |
3) When invoking php.exe, you can still receive one warning regarding php_yaz.dll not having been found.
This is most probably due to some incompatibility between your version of PHP and the version of this extension. This fix the issue, edit your php.ini
file inside EasyPHP\php\php546x120925133033
and comment out the line that says:
1 |
extension=php_yaz.dll |
Enjoy your web development with Yii! 🙂
12 Comments
thank you it help me a lot!!! 🙂
You are welcome! 🙂
This helped me as well. Thank you for posting this.
My pleasure!
I was having a similar problem using Laravel and it helped me. Thank you!
You are welcome, glad it helped! 🙂
Good job. I was stuck into this problem for more than 8 hours , Nice job Dude
Great, glad it helped you! 🙂
Thanks It worked for me too.We need to set correct paths in yiic bat file in order to it work
Thanks again
You are welcome Vishal! Glad you could solve your problem.
Thank you very much, this is the best explanation I found on the web 🙂 I waste 3 hours of my time to solve problem, with your explanation I lose 5 minutes
Great, glad you solved your problem.