简体   繁体   中英

PHP error when i use Webception and wamp server

When I try to use Webception over wamp server on my windows 7,8 the below error appears for each tests

'php' is not recognized as an internal or external command,operable program or batch file

I have already installed php and the path is correct. Does it need more setup? How I can fix this issue ASAP?

This is because windows does not know where to find the php.exe file as it is not in a folder that is on your PATH environment variable.

However, when using WAMPServer it is a VERY BAD IDEA to add the path containing the php.exe to your PATH in the traditional way, because of course in WAMPServer it is possible to have many version of PHP available within one instance of WAMPServer.

The best solution in a WAMPServer environment is to create yourself a little command file that you can run from within a command windows that will add the php path you want to use for this specific project.

So create yourself a .cmd file and place THAT file in a folder that is already on your windows PATH environement variable.

So for example :-

File = phppath.cmd

PATH=%PATH%;c:\wamp\bin\php\php5.5.12
ECHO --------------------------------------------
php -v
ECHO --------------------------------------------

Of course you can make this as clever as you like and accept parameter specifying the php version you want to run, but untill you actually have more than one PHP version installed this is good enough.

I was also having a problem with webception on wamp failing to find php despite it being available on user and system path. I found that wamp on windows by default does not provide environment variables to PHP. I fixed this by editing php.ini (in apache/apache/bin/php.ini) and ensuring that the following is set

variables_order = "EGPCS"

As at the current webception version 0.1.0 there is a bug to do with path generation that fails tests because the test file cannot be found. There is a solution for this at https://github.com/syntithenai/Webception/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM