php.exe is not recognized as an internal or external command.

"php.exe is not recognized as an internal or external command", this was the message i received when i tired to install the yiic framework for the first time.

i figured it out eventually and here are the details:

you can solve this in two ways.

first method : edit the yiic.bat file.

you can modified the yiic.bat file in \YiiPath\framework\yiic.bat

find the path where php.exe resides on your disk, and simply add the line

cd C:\Program Files\PHPexeFolder\

on top of

%PHP_COMMAND% "%YII_PATH%yiic" %*

now save the yiic.bat file and run it.

second method : add the path to the system variables.

right click "my computer" go to "system properties" under "advanced" tab, click on "environment variables"

under "system variables" find for the variable named "PATH" and click on "Edit" button

in "Variable Value" append the php.exe path with a semi-colon like below (without the inverted commas)

";C:\Program Files\PHPexeFolder\"

Hope this helps anybody :)

Ganna…

[size=2]Hi![/size]

I think I do exactly the way you discribe.

I still have the same error.

After editing the bat-file it look like this:

@setlocal

set YII_PATH=%~dp0

if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe

cd C:\xampp\xampp\php

%PHP_COMMAND% "%YII_PATH%yiic" %*

@endlocal

Is this wrong??

Hope for help

/Christer

i had the same issues as you. The only way it worked was to include the path to the php.exe in the environment variables and in the command prompt (from anywhere)

php path\to\framework\directory\yiic.php webapp path\to\www (for example. php c:\wamp\framework\yiic.php webapp c:\wamp\www\myapp

I used this with wamp 2.0/windows 7

Hope that helps

Hi all, I think this is the perfect content for a WIKI article… Anyone?

Once registered, anybody can write one and I think is great content

Hi, I’m just getting started with Yii and this thread helped me past the first stumbling block so I’ll have a go at writing this up as a wiki article.

Sadly I’m ‘too new’ to write a wiki article, but here is my collated version of this thread in case someone else can copy and paste it into the wiki.

Using yiic on Windows - PHP is not recognised

Step 1: Edit the yiic.bat file.

Located \YiiPath\framework\yiic.bat

find the path where php.exe resides on your disk, and add the line

cd C:\Program Files\PHPexeFolder\

above

%PHP_COMMAND% "%YII_PATH%yiic" %*

Step 2: Add the PHP path to the system variables.

Right click "my computer" go to "system properties" under "advanced" tab, click on "environment variables"

Under "system variables" find for the variable named "PATH" and click on "Edit" button

in "Variable Value" append the php.exe path with a semi-colon to the end of current string like below (without the inverted commas)

";C:\Program Files\PHPexeFolder\"

Step 3: Open command prompt, run the following with paths beginning with your drive letter e.g. C:\

php C:\path\to\framework\directory\yiic.php webapp C:\path\to\newwebappfolder (for example. php c:\wamp\framework\yiic.php webapp c:\wamp\www\myapp

Sources: This article is a quick write-up of a forum thread:

http://www.yiiframework.com/forum/index.php?/topic/12712-phpexe-is-not-recognized-as-an-internal-or-external-command/

Further reading: Yii and XAMPP server on Windows

http://www.yiiframework.com/wiki/100/yii-and-xampp-server-on-windows

Let me add a much simpler way… At least for me…

Look at the paragraph in this link Larry explains it REALLY well and the whole free guide is worth following…

So search for where php.exe is on our system… In my case it was c:/php

Then in the directory where yiic is type c:/php/php.exe yiic webdev and bingo the site is created…

Superb

George

Hi, I had the same problem. I had to write in shell:


cd C:\ComplexWebServer/http_docs

"C:\ComplexWebServer\php5\bin\php.exe" YiiMain/framework/yiic.php webapp demo

ComplexWebServer was my software like xampp. Later I had problem with installing phpunit, so I changed it to xampp and everything worked (I found that paths to php.ini in "$ php --ini" and phpinfo are different in my old software and nothing helped)

But I found really good idea how to create application in Yii.

In http_docs create file generator.bat. Insert code (f.e.):


"C:\ComplexWebServer\php5\bin\php.exe" YiiMain/framework/yiic.php webapp demo 

Then only click on this file in folder. I only changed name of aplication every time, then clicked and everything worked.

It’s not my idea, I found in YTB tutorial (It’s propably Spanish, I watched only video - www.youtube.com/watch?v=tDPyQSFcq98)

But because I haven’t problem with paths, I use shell now.

on path windows

environment variables on




%path%;C:\xampp\php\<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/grin.gif' class='bbc_emoticon' alt=';D' />:\wwwroot\yiiframework\



on cmd.exe




D:\wwwroot>yiic webapp myblogyii



i hope working

I had all this problems too, and i found a great solution for who are using Xammp/Windows:

in cmd.exe

1 step

c:\> cd xampp\htdocs\yii\framework //the path where you have the yii framework

2 step

c:\xampp\htdocs\yii\framework> c:\xampp\php\php.exe yiic webapp c:\xampp\htdocs\yourappname

3 step

Ask if you want create the app and you write "yes"

app created!

i hope this helps!

This is not really a “great” solution. :)

It works, but it’s far better to add the path to the php client executable and the path to yiic (in yii/framework) to your PATH environment variable.

It’s no big deal. ;)

Second method helped. First method did not. Thanks .

Indeed.

And the second method is what is recommended that you do. :)

@soulgers : Thanks it works for me