Have green icon but php program not running
Posted by: havelly (---.dyn.iinet.net.au)
Date: December 18, 2014 02:59AM

Hello Riggs

I have a green icon and got a list of details after clicking phpinfo() - so this would appear to indicate the installation was successful.

When I went to run a program, "php sayHello.php" was typed into the command line (Windows).

The response was:

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

While looking at the phpinfo() output, under the "PHP Variables" heading there is a _SERVER["PATHEXT"] listing which covers the following extensions:

COM, EXE, BAT, CMD, VBS, VBE, JS, JSE, WSF, WSH

The PHP extension is not included.

Is this significant?

I'm not sure whether or not this is a PHP issue. Can you shine any light on this?

regards
havelly

Options: ReplyQuote
Re: Have green icon but php program not running
Posted by: RiggsFolly (---.as43234.net)
Date: December 18, 2014 10:20AM

Hi Havelly,

Just like any other executable in windows, windows need to know where to look for your php.exe program.

Because in WAMPServer you can actually switch between any number of PHP versions easily, it is a VERY BAD idea to add a specific version of PHP to the Windows PATH although you may see that suggested on many blogs (There is lots of data out there, but very little good information).

I use the following mechanism :-

So that I can open a command windows any time I like and temporarily, add the version of PHP I currently want to run to the Windows PATH, I created this little batch file :-

Called phppath.cmd
echo off
if %1.==. GOTO THEDEFAULT
ECHO Setting up PHP%1
PATH=%PATH%;d:\wamp\bin\php\php%1

REM ONLY UNCOMMENT THESE LINES IF YOU HAVE INSTALLED PEAR ON YOUR SYSTEM
REM set PHP_PEAR_SYSCONF_DIR=D:\wamp\bin\php\php%1
REM set PHP_PEAR_INSTALL_DIR=D:\wamp\bin\php\php%1\pear
REM set PHP_PEAR_DOC_DIR=D:\wamp\bin\php\php%1\docs
REM set PHP_PEAR_BIN_DIR=D:\wamp\bin\php\php%1
REM set PHP_PEAR_DATA_DIR=D:\wamp\bin\php\php%1\data
REM set PHP_PEAR_PHP_BIN=D:\wamp\bin\php\php%1\php.exe
REM set PHP_PEAR_TEST_DIR=D:\wamp\bin\php\php%1\tests
echo ---------------------------------------------------------------
php -v
echo ---------------------------------------------------------------
GOTO END

:THEDEFAULT
echo Taking the default version php5.5.12
echo .
PATH=%PATH%;d:\wamp\bin\php\php5.5.12
REM set PHP_PEAR_SYSCONF_DIR=D:\wamp\bin\php\php5.5.12
REM set PHP_PEAR_INSTALL_DIR=D:\wamp\bin\php\php5.5.12\pear
REM set PHP_PEAR_DOC_DIR=D:\wamp\bin\php\php5.5.12\docs
REM set PHP_PEAR_BIN_DIR=D:\wamp\bin\php\php5.5.12
REM set PHP_PEAR_DATA_DIR=D:\wamp\bin\php\php5.5.12\data
REM set PHP_PEAR_PHP_BIN=D:\wamp\bin\php\php5.5.12\php.exe
REM set PHP_PEAR_TEST_DIR=D:\wamp\bin\php\php5.5.12\tests
echo ---------------------------------------------------------------
php -v
echo ---------------------------------------------------------------

:END



Now the idea is to put this .cmd file into a folder that is already on the Windows PATH so it can be run from anywhere.

So when you want to run a PHP CLI script, you open a command windows
CD into any folder containing your .php scripts
and then run this file like this,

To use the default PHP version you do

phppath

To use a specific php version you do

phppath 5.4.11

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Have green icon but php program not running
Posted by: havelly (---.dyn.iinet.net.au)
Date: December 19, 2014 12:19AM

Hello Riggs

Again, thank you for your assistance.

regards
Havelly

Options: ReplyQuote


Sorry, only registered users may post in this forum.