Cannot run a php program from the command line
Posted by: edfactor (---.dllstx.fios.verizon.net)
Date: January 23, 2014 08:03PM

My problem is that I am trying to learn PHP and having just started this I downloaded WAMP and installed it. Now when I tried to run my first PHP program I receive the error:

PHP is not recognized as an internal or external command, operable program or batch file.


Version of Operating system: Windows 7 (64 bit)
I downloaded and installed: Apache 2.2.22 – Mysql 5.5.24 – PHP 5.3.13 XDebug 2.1.2 XDC 1.5 PhpMyadmin 3.4.10.1 SQLBuddy 1.3.3 webGrind 1.0

What colour is your WampManager icon? The Icon is green


Do you have a HOSTS file? [c:\windows\system32\drivers\etc\hosts] Yes I do see a hosts file


Paste any entries relating to the domain localhost and also any relating to your Virtual Hosts if you have any.

# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost

127.0.0.1 localhost
127.0.0.1 localhost



I can go to local host and select the phpinfo() link:

System Windows NT HOME-PC 6.1 build 7601 (Windows 7 Home Premium Edition Service Pack 1) AMD64
Build Date May 14 2012 02:46:11
Compiler MSVC9 (Visual C++ 2008)
Architecture x64
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-pdo-oci=C:\php-sdk\php53dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "--with-oci8=C:\php-sdk\php53dev\vc9\x64\deps\instantclient_10_2\sdk,shared" "--with-oci8-11g=C:\php-sdk\php53dev\vc9\x64\deps\instantclient_11_2\sdk,shared" "--disable-debug-pack" "--disable-static-analyze"
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\Windows
Loaded Configuration File C:\wamp\bin\apache\apache2.2.22\bin\php.ini
Scan this dir for additional .ini files (none)
Additional .ini files parsed (none)
PHP API 20090626
PHP Extension 20090626
Zend Extension 220090626
Zend Extension Build API220090626,TS,VC9
PHP Extension Build API20090626,TS,VC9
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
Zend Multibyte Support disabled
IPv6 Support enabled
Registered PHP Streams php, file, glob, data, http, ftp, zip, compress.zlib, phar
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv.*, mcrypt.*, mdecrypt.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, zlib.*

Options: ReplyQuote
Re: Cannot run a php program from the command line
Posted by: stevenmartin99 (Moderator)
Date: January 23, 2014 10:15PM

php.exe is not setup as an enviornmental variable by default.

you will need to navigate the path prompt in cmd to c:\wamp\bin\php\phpx.x.x.\php.exe


you can also drop php scripts onto the php-win.exe in c:\wamp\bin\php\phpx.x.x\ to run them as CLI with out having to open the cmd prompt

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Cannot run a php program from the command line
Posted by: edfactor (---.dllstx.fios.verizon.net)
Date: January 23, 2014 10:42PM

Thank you, I added the path c:\wamp\bin\php\php5.3.13\ to my environment variables and it works now!

Options: ReplyQuote


Sorry, only registered users may post in this forum.