Proper Way to CLI PHP within WAMP (WAMP64), while switching between Multiple PHP Versions on Windows 10How To Run PHP From Windows Command Line in WAMPServercommand line locally using wampCan't Run PHP Imagick from Command Line?PHP cURL not working - WAMP on Windows 7 64 bitHow to change php-cli Version (Wamp)How to upgrade php version on Windows 10Use PHP 7.0.10 on CLI with WAMPUnable to install PHP CodeSniffer in wamp or xampp in windows 10 systemWAMP and PEAR PHP version change, PEAR Version doesn't matchthere is wamp server path (c /wamp64) into windows path environment variable in C:wampbinphpphp7.1.16 C:wampbinphpphp7.1.16Wamp stoped working after i installed Composer in-light mecomposer php wamp 3.1.4 windows environment path conflictwamp server error path is not specified after update
Simply connected compact Lie groups have even dimension - Where is the mistake?
How do I keep my animals from eating my people food?
Do universities maintain secret textbooks?
Eliminate key lookup in execution plan
What's the difference between a variable and a memory location?
How did medieval manors handle population growth? Was there room for more fields to be ploughed?
What is ArcStorm from Esri?
Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?
Is this homebrew "Faerie Fire Grenade" unbalanced?
How to animate a function plot
Group riding etiquette
What are the in-game differences between WoW Classic and the original 2006 Version
Necessity of tenure for lifetime academic research
Was a six-engine 747 ever seriously considered by Boeing?
Who declared the Last Alliance to be the "last" and why?
Is it possible for a person to be tricked into becoming a lich?
Can I leave a large suitcase at TPE during a 4-hour layover, and pick it up 4.5 days later when I come back to TPE on my way to Taipei downtown?
In what language did Túrin converse with Mím?
In Endgame, wouldn't Stark have remembered Hulk busting out of the stairwell?
Are sweatpants frowned upon on flights?
Eshet Chayil in the Tunisian service
Was it illegal to blaspheme God in Antioch in 360.-410.?
What's the origin of the concept of alternate dimensions/realities?
Don't look at what I did there
Proper Way to CLI PHP within WAMP (WAMP64), while switching between Multiple PHP Versions on Windows 10
How To Run PHP From Windows Command Line in WAMPServercommand line locally using wampCan't Run PHP Imagick from Command Line?PHP cURL not working - WAMP on Windows 7 64 bitHow to change php-cli Version (Wamp)How to upgrade php version on Windows 10Use PHP 7.0.10 on CLI with WAMPUnable to install PHP CodeSniffer in wamp or xampp in windows 10 systemWAMP and PEAR PHP version change, PEAR Version doesn't matchthere is wamp server path (c /wamp64) into windows path environment variable in C:wampbinphpphp7.1.16 C:wampbinphpphp7.1.16Wamp stoped working after i installed Composer in-light mecomposer php wamp 3.1.4 windows environment path conflictwamp server error path is not specified after update
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Used to just put the wamp php directory in my system environment variables as answered here: command line locally using wamp. Which more or less is a very simple environmental variable edit adding the WAMP servers PHP Path, such as ;C:wampbinphpphp5.6.40
I'm now learning with more recent versions WAMP is recommending against doing so (as shown here: How To Run PHP From Windows Command Line in WAMPServer).
In that answer it shows a clever command line/.cmd
program named phppath.cmd
which is tailored to linux users.
Unedited, it looks as such:
@echo off
REM **************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM **************************************************************
set baseWamp=D:wamp
set defaultPHPver=7.1.9
set composerInstalled=%baseWamp%composer
set phpFolder=binphpphp
if %1.==. (
set phpver=%baseWamp%%phpFolder%%defaultPHPver%
) else (
set phpver=%baseWamp%%phpFolder%%1
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=D:wampbinphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=D:wampbinphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_DATA_DIR=D:wampbinphpphp%phpver%data
set PHP_PEAR_PHP_BIN=D:wampbinphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=D:wampbinphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=%baseWamp%composer
set COMPOSER_CACHE_DIR=%baseWamp%composer
PATH=%PATH%;%baseWamp%composer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
This sounds great, but I'm having mild success with it.
How it works, is I place the phppath.cmd
file into my Windows directory and it autoloads when windows starts.
The linux-windows conversions may have messed with me a little bit, but here's my edited output for Windows 10 WAMP64 (current one in my C:Windows
folder)
@echo off
REM **********************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Serch path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I insatlled composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM **********************************************************************
set baseWamp=C:wamp64
set defaultPHPver=7.1.26
set composerInstalled=C:UsersUserAppDataRoamingComposer
set phpFolder=C:wamp64binphp
if %1.==. (
set phpver=C:wamp64binphpphp%defaultPHPver%
) else (
set phpver=C:wamp64binphpphp
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=C:wamp64binphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=C:wamp64binphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_DATA_DIR=C:wamp64binphpphp%phpver%data
set PHP_PEAR_PHP_BIN=C:wamp64binphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=C:wamp64binphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=C:UsersUserAppDataRoamingComposer
set COMPOSER_CACHE_DIR=C:UsersUserAppDataRoamingComposer
PATH=%PATH%;C:UsersUserAppDataRoamingComposer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
Here's where my confusion is setting in.
Using the command prompt phppath
in a command line I get the following output
PHP 7.1.26 (cli) (built: Jan 9 2019 21:51:32) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Additionally I cannot change my PHP version using the phppath command line.
The versions on my WAMP64 installation consist of 5.6.40
- 7.0.33
- 7.1.26
- 7.2.14
- 7.3.1
What I am trying to do (and though phppath.cmd
would achieve that), is, as seen in that thread, change php CLI versions with a simple command.
phppath 5.6.40
phppath 7.0.33
etc
but these commands are ineffective, they process properly, put the command line always states PHP 7.1.26 (cli)
no matter if its specified.
Did I mess up my paths or something when I tried to convert the above script from linux to Windows 10? I tried to make sure all the paths were appropriate.
edit: Using W10 x64 version WAMP 3.1.7. Read there were issues using Powershell, or rather phppath.cmd
was not designed for powershell, so I'm using the program Cmder
for command line functions.
edit 2: Figured out php 7.1.26 was indeed in my environmental variables.. I was only looking at USER env variables. Somehow it got into SYSTEM env variables (not completely sure how). Deleted that entry which may have been causing conflicts. Onto some more testing..
Now to just get phppath.cmd
to work properly.
edit3: Last edit for now.. I'll try to mess with this more later, if anyone has any insight please provide! So as I stated the wamp php directory was in the system environmental variables, once I removed that entry the error message [ERROR C:/wamp64 or PHP in path.
] in WAMP went away.
As to switch / change between PHP CLI versions -- as of right now, kind of a band-aid solution, but workable... if I just change my phppath.cmd
file in my C:Windows
folder from set defaultPHPver=7.1.26
to another version like set defaultPHPver=7.0.33
or set defaultPHPver=5.6.40
--- that works to change the PHP CLI version using phppath on the commandline (AFTER a restart).
How it appears to be working is...
(manually set defaultpath in cmd file...)...
Open up a CLI like cmder
type in..
phppath
(here I have in my phppath.cmd a default version of 7.0.x)
PHP 7.0.33 (cli) (built: Dec 5 2018 21:22:29) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Then I can continue to use the default php
CLI functions..
php -f version.php
Current version is PHP 7.0.33
Note: If I don't initiate by using the command phppath
first I get the typical error message -- 'php' is not recognized as an internal or external command,
, so typing
operable program or batch file.phppath
is required for the php
commands to work.
So this is great and workable for now. I just have to manually edit the phppath.cmd
to the default version I want it to be and reset my computer.
Only issue is that, per the instructions, phppath.cmd
should be able to change PHP CLI version on the fly using the commands I attempted above. This is of course better than having to manually edit the .cmd file and restart everytime I want to change the version.
Anyone have any insight as to why my Windows 10 modified phppath.cmd
won't change versions via the command line, only by modifying the file and doing a computer restart? Would be much appreciated... last step to get down :)
edit: The comments got kind of long, to summarize defining %PATH%
as pathBak
was indeed the answer, as shown in @michael_heath Using the script below works exactly as it should on my Windows 10 machine, version changing and all.
php windows batch-file cmd command-line
add a comment |
Used to just put the wamp php directory in my system environment variables as answered here: command line locally using wamp. Which more or less is a very simple environmental variable edit adding the WAMP servers PHP Path, such as ;C:wampbinphpphp5.6.40
I'm now learning with more recent versions WAMP is recommending against doing so (as shown here: How To Run PHP From Windows Command Line in WAMPServer).
In that answer it shows a clever command line/.cmd
program named phppath.cmd
which is tailored to linux users.
Unedited, it looks as such:
@echo off
REM **************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM **************************************************************
set baseWamp=D:wamp
set defaultPHPver=7.1.9
set composerInstalled=%baseWamp%composer
set phpFolder=binphpphp
if %1.==. (
set phpver=%baseWamp%%phpFolder%%defaultPHPver%
) else (
set phpver=%baseWamp%%phpFolder%%1
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=D:wampbinphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=D:wampbinphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_DATA_DIR=D:wampbinphpphp%phpver%data
set PHP_PEAR_PHP_BIN=D:wampbinphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=D:wampbinphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=%baseWamp%composer
set COMPOSER_CACHE_DIR=%baseWamp%composer
PATH=%PATH%;%baseWamp%composer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
This sounds great, but I'm having mild success with it.
How it works, is I place the phppath.cmd
file into my Windows directory and it autoloads when windows starts.
The linux-windows conversions may have messed with me a little bit, but here's my edited output for Windows 10 WAMP64 (current one in my C:Windows
folder)
@echo off
REM **********************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Serch path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I insatlled composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM **********************************************************************
set baseWamp=C:wamp64
set defaultPHPver=7.1.26
set composerInstalled=C:UsersUserAppDataRoamingComposer
set phpFolder=C:wamp64binphp
if %1.==. (
set phpver=C:wamp64binphpphp%defaultPHPver%
) else (
set phpver=C:wamp64binphpphp
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=C:wamp64binphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=C:wamp64binphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_DATA_DIR=C:wamp64binphpphp%phpver%data
set PHP_PEAR_PHP_BIN=C:wamp64binphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=C:wamp64binphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=C:UsersUserAppDataRoamingComposer
set COMPOSER_CACHE_DIR=C:UsersUserAppDataRoamingComposer
PATH=%PATH%;C:UsersUserAppDataRoamingComposer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
Here's where my confusion is setting in.
Using the command prompt phppath
in a command line I get the following output
PHP 7.1.26 (cli) (built: Jan 9 2019 21:51:32) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Additionally I cannot change my PHP version using the phppath command line.
The versions on my WAMP64 installation consist of 5.6.40
- 7.0.33
- 7.1.26
- 7.2.14
- 7.3.1
What I am trying to do (and though phppath.cmd
would achieve that), is, as seen in that thread, change php CLI versions with a simple command.
phppath 5.6.40
phppath 7.0.33
etc
but these commands are ineffective, they process properly, put the command line always states PHP 7.1.26 (cli)
no matter if its specified.
Did I mess up my paths or something when I tried to convert the above script from linux to Windows 10? I tried to make sure all the paths were appropriate.
edit: Using W10 x64 version WAMP 3.1.7. Read there were issues using Powershell, or rather phppath.cmd
was not designed for powershell, so I'm using the program Cmder
for command line functions.
edit 2: Figured out php 7.1.26 was indeed in my environmental variables.. I was only looking at USER env variables. Somehow it got into SYSTEM env variables (not completely sure how). Deleted that entry which may have been causing conflicts. Onto some more testing..
Now to just get phppath.cmd
to work properly.
edit3: Last edit for now.. I'll try to mess with this more later, if anyone has any insight please provide! So as I stated the wamp php directory was in the system environmental variables, once I removed that entry the error message [ERROR C:/wamp64 or PHP in path.
] in WAMP went away.
As to switch / change between PHP CLI versions -- as of right now, kind of a band-aid solution, but workable... if I just change my phppath.cmd
file in my C:Windows
folder from set defaultPHPver=7.1.26
to another version like set defaultPHPver=7.0.33
or set defaultPHPver=5.6.40
--- that works to change the PHP CLI version using phppath on the commandline (AFTER a restart).
How it appears to be working is...
(manually set defaultpath in cmd file...)...
Open up a CLI like cmder
type in..
phppath
(here I have in my phppath.cmd a default version of 7.0.x)
PHP 7.0.33 (cli) (built: Dec 5 2018 21:22:29) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Then I can continue to use the default php
CLI functions..
php -f version.php
Current version is PHP 7.0.33
Note: If I don't initiate by using the command phppath
first I get the typical error message -- 'php' is not recognized as an internal or external command,
, so typing
operable program or batch file.phppath
is required for the php
commands to work.
So this is great and workable for now. I just have to manually edit the phppath.cmd
to the default version I want it to be and reset my computer.
Only issue is that, per the instructions, phppath.cmd
should be able to change PHP CLI version on the fly using the commands I attempted above. This is of course better than having to manually edit the .cmd file and restart everytime I want to change the version.
Anyone have any insight as to why my Windows 10 modified phppath.cmd
won't change versions via the command line, only by modifying the file and doing a computer restart? Would be much appreciated... last step to get down :)
edit: The comments got kind of long, to summarize defining %PATH%
as pathBak
was indeed the answer, as shown in @michael_heath Using the script below works exactly as it should on my Windows 10 machine, version changing and all.
php windows batch-file cmd command-line
add a comment |
Used to just put the wamp php directory in my system environment variables as answered here: command line locally using wamp. Which more or less is a very simple environmental variable edit adding the WAMP servers PHP Path, such as ;C:wampbinphpphp5.6.40
I'm now learning with more recent versions WAMP is recommending against doing so (as shown here: How To Run PHP From Windows Command Line in WAMPServer).
In that answer it shows a clever command line/.cmd
program named phppath.cmd
which is tailored to linux users.
Unedited, it looks as such:
@echo off
REM **************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM **************************************************************
set baseWamp=D:wamp
set defaultPHPver=7.1.9
set composerInstalled=%baseWamp%composer
set phpFolder=binphpphp
if %1.==. (
set phpver=%baseWamp%%phpFolder%%defaultPHPver%
) else (
set phpver=%baseWamp%%phpFolder%%1
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=D:wampbinphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=D:wampbinphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_DATA_DIR=D:wampbinphpphp%phpver%data
set PHP_PEAR_PHP_BIN=D:wampbinphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=D:wampbinphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=%baseWamp%composer
set COMPOSER_CACHE_DIR=%baseWamp%composer
PATH=%PATH%;%baseWamp%composer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
This sounds great, but I'm having mild success with it.
How it works, is I place the phppath.cmd
file into my Windows directory and it autoloads when windows starts.
The linux-windows conversions may have messed with me a little bit, but here's my edited output for Windows 10 WAMP64 (current one in my C:Windows
folder)
@echo off
REM **********************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Serch path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I insatlled composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM **********************************************************************
set baseWamp=C:wamp64
set defaultPHPver=7.1.26
set composerInstalled=C:UsersUserAppDataRoamingComposer
set phpFolder=C:wamp64binphp
if %1.==. (
set phpver=C:wamp64binphpphp%defaultPHPver%
) else (
set phpver=C:wamp64binphpphp
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=C:wamp64binphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=C:wamp64binphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_DATA_DIR=C:wamp64binphpphp%phpver%data
set PHP_PEAR_PHP_BIN=C:wamp64binphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=C:wamp64binphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=C:UsersUserAppDataRoamingComposer
set COMPOSER_CACHE_DIR=C:UsersUserAppDataRoamingComposer
PATH=%PATH%;C:UsersUserAppDataRoamingComposer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
Here's where my confusion is setting in.
Using the command prompt phppath
in a command line I get the following output
PHP 7.1.26 (cli) (built: Jan 9 2019 21:51:32) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Additionally I cannot change my PHP version using the phppath command line.
The versions on my WAMP64 installation consist of 5.6.40
- 7.0.33
- 7.1.26
- 7.2.14
- 7.3.1
What I am trying to do (and though phppath.cmd
would achieve that), is, as seen in that thread, change php CLI versions with a simple command.
phppath 5.6.40
phppath 7.0.33
etc
but these commands are ineffective, they process properly, put the command line always states PHP 7.1.26 (cli)
no matter if its specified.
Did I mess up my paths or something when I tried to convert the above script from linux to Windows 10? I tried to make sure all the paths were appropriate.
edit: Using W10 x64 version WAMP 3.1.7. Read there were issues using Powershell, or rather phppath.cmd
was not designed for powershell, so I'm using the program Cmder
for command line functions.
edit 2: Figured out php 7.1.26 was indeed in my environmental variables.. I was only looking at USER env variables. Somehow it got into SYSTEM env variables (not completely sure how). Deleted that entry which may have been causing conflicts. Onto some more testing..
Now to just get phppath.cmd
to work properly.
edit3: Last edit for now.. I'll try to mess with this more later, if anyone has any insight please provide! So as I stated the wamp php directory was in the system environmental variables, once I removed that entry the error message [ERROR C:/wamp64 or PHP in path.
] in WAMP went away.
As to switch / change between PHP CLI versions -- as of right now, kind of a band-aid solution, but workable... if I just change my phppath.cmd
file in my C:Windows
folder from set defaultPHPver=7.1.26
to another version like set defaultPHPver=7.0.33
or set defaultPHPver=5.6.40
--- that works to change the PHP CLI version using phppath on the commandline (AFTER a restart).
How it appears to be working is...
(manually set defaultpath in cmd file...)...
Open up a CLI like cmder
type in..
phppath
(here I have in my phppath.cmd a default version of 7.0.x)
PHP 7.0.33 (cli) (built: Dec 5 2018 21:22:29) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Then I can continue to use the default php
CLI functions..
php -f version.php
Current version is PHP 7.0.33
Note: If I don't initiate by using the command phppath
first I get the typical error message -- 'php' is not recognized as an internal or external command,
, so typing
operable program or batch file.phppath
is required for the php
commands to work.
So this is great and workable for now. I just have to manually edit the phppath.cmd
to the default version I want it to be and reset my computer.
Only issue is that, per the instructions, phppath.cmd
should be able to change PHP CLI version on the fly using the commands I attempted above. This is of course better than having to manually edit the .cmd file and restart everytime I want to change the version.
Anyone have any insight as to why my Windows 10 modified phppath.cmd
won't change versions via the command line, only by modifying the file and doing a computer restart? Would be much appreciated... last step to get down :)
edit: The comments got kind of long, to summarize defining %PATH%
as pathBak
was indeed the answer, as shown in @michael_heath Using the script below works exactly as it should on my Windows 10 machine, version changing and all.
php windows batch-file cmd command-line
Used to just put the wamp php directory in my system environment variables as answered here: command line locally using wamp. Which more or less is a very simple environmental variable edit adding the WAMP servers PHP Path, such as ;C:wampbinphpphp5.6.40
I'm now learning with more recent versions WAMP is recommending against doing so (as shown here: How To Run PHP From Windows Command Line in WAMPServer).
In that answer it shows a clever command line/.cmd
program named phppath.cmd
which is tailored to linux users.
Unedited, it looks as such:
@echo off
REM **************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM **************************************************************
set baseWamp=D:wamp
set defaultPHPver=7.1.9
set composerInstalled=%baseWamp%composer
set phpFolder=binphpphp
if %1.==. (
set phpver=%baseWamp%%phpFolder%%defaultPHPver%
) else (
set phpver=%baseWamp%%phpFolder%%1
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=D:wampbinphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=D:wampbinphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=D:wampbinphpphp%phpver%
set PHP_PEAR_DATA_DIR=D:wampbinphpphp%phpver%data
set PHP_PEAR_PHP_BIN=D:wampbinphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=D:wampbinphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=%baseWamp%composer
set COMPOSER_CACHE_DIR=%baseWamp%composer
PATH=%PATH%;%baseWamp%composer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
This sounds great, but I'm having mild success with it.
How it works, is I place the phppath.cmd
file into my Windows directory and it autoloads when windows starts.
The linux-windows conversions may have messed with me a little bit, but here's my edited output for Windows 10 WAMP64 (current one in my C:Windows
folder)
@echo off
REM **********************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Serch path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I insatlled composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM **********************************************************************
set baseWamp=C:wamp64
set defaultPHPver=7.1.26
set composerInstalled=C:UsersUserAppDataRoamingComposer
set phpFolder=C:wamp64binphp
if %1.==. (
set phpver=C:wamp64binphpphp%defaultPHPver%
) else (
set phpver=C:wamp64binphpphp
)
PATH=%PATH%;%phpver%
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
IF exist %phpver%pear (
set PHP_PEAR_SYSCONF_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_INSTALL_DIR=C:wamp64binphpphp%phpver%pear
set PHP_PEAR_DOC_DIR=C:wamp64binphpphp%phpver%docs
set PHP_PEAR_BIN_DIR=C:wamp64binphpphp%phpver%
set PHP_PEAR_DATA_DIR=C:wamp64binphpphp%phpver%data
set PHP_PEAR_PHP_BIN=C:wamp64binphpphp%phpver%php.exe
set PHP_PEAR_TEST_DIR=C:wamp64binphpphp%phpver%tests
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer
REM *
REM **************************************************************
IF EXIST %composerInstalled% (
ECHO COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set COMPOSER_HOME=C:UsersUserAppDataRoamingComposer
set COMPOSER_CACHE_DIR=C:UsersUserAppDataRoamingComposer
PATH=%PATH%;C:UsersUserAppDataRoamingComposer
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
set baseWamp=
set defaultPHPver=
set composerInstalled=
set phpFolder=
Here's where my confusion is setting in.
Using the command prompt phppath
in a command line I get the following output
PHP 7.1.26 (cli) (built: Jan 9 2019 21:51:32) ( ZTS MSVC14 (Visual C++ 2015) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Additionally I cannot change my PHP version using the phppath command line.
The versions on my WAMP64 installation consist of 5.6.40
- 7.0.33
- 7.1.26
- 7.2.14
- 7.3.1
What I am trying to do (and though phppath.cmd
would achieve that), is, as seen in that thread, change php CLI versions with a simple command.
phppath 5.6.40
phppath 7.0.33
etc
but these commands are ineffective, they process properly, put the command line always states PHP 7.1.26 (cli)
no matter if its specified.
Did I mess up my paths or something when I tried to convert the above script from linux to Windows 10? I tried to make sure all the paths were appropriate.
edit: Using W10 x64 version WAMP 3.1.7. Read there were issues using Powershell, or rather phppath.cmd
was not designed for powershell, so I'm using the program Cmder
for command line functions.
edit 2: Figured out php 7.1.26 was indeed in my environmental variables.. I was only looking at USER env variables. Somehow it got into SYSTEM env variables (not completely sure how). Deleted that entry which may have been causing conflicts. Onto some more testing..
Now to just get phppath.cmd
to work properly.
edit3: Last edit for now.. I'll try to mess with this more later, if anyone has any insight please provide! So as I stated the wamp php directory was in the system environmental variables, once I removed that entry the error message [ERROR C:/wamp64 or PHP in path.
] in WAMP went away.
As to switch / change between PHP CLI versions -- as of right now, kind of a band-aid solution, but workable... if I just change my phppath.cmd
file in my C:Windows
folder from set defaultPHPver=7.1.26
to another version like set defaultPHPver=7.0.33
or set defaultPHPver=5.6.40
--- that works to change the PHP CLI version using phppath on the commandline (AFTER a restart).
How it appears to be working is...
(manually set defaultpath in cmd file...)...
Open up a CLI like cmder
type in..
phppath
(here I have in my phppath.cmd a default version of 7.0.x)
PHP 7.0.33 (cli) (built: Dec 5 2018 21:22:29) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
---------------------------------------------------------------
PEAR DOES NOT EXIST IN THIS VERSION OF php
---------------------------------------------------------------
COMPOSER INCLUDED IN THIS CONFIG
---------------------------------------------------------------
---------------------------------------------------------------
Then I can continue to use the default php
CLI functions..
php -f version.php
Current version is PHP 7.0.33
Note: If I don't initiate by using the command phppath
first I get the typical error message -- 'php' is not recognized as an internal or external command,
, so typing
operable program or batch file.phppath
is required for the php
commands to work.
So this is great and workable for now. I just have to manually edit the phppath.cmd
to the default version I want it to be and reset my computer.
Only issue is that, per the instructions, phppath.cmd
should be able to change PHP CLI version on the fly using the commands I attempted above. This is of course better than having to manually edit the .cmd file and restart everytime I want to change the version.
Anyone have any insight as to why my Windows 10 modified phppath.cmd
won't change versions via the command line, only by modifying the file and doing a computer restart? Would be much appreciated... last step to get down :)
edit: The comments got kind of long, to summarize defining %PATH%
as pathBak
was indeed the answer, as shown in @michael_heath Using the script below works exactly as it should on my Windows 10 machine, version changing and all.
php windows batch-file cmd command-line
php windows batch-file cmd command-line
edited Mar 28 at 7:50
Brian Bruman
asked Mar 27 at 23:03
Brian BrumanBrian Bruman
4583 silver badges12 bronze badges
4583 silver badges12 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In line 20 of unedited:
set phpver=%baseWamp%%phpFolder%%1
compared to line 28 of edited:
set phpver=C:wamp64binphpphp
The %1
is the variable that contains the value of the 1st script argument.
The edited version is missing %1
so it does not change version,
but rather uses the fixed path. This may be your main issue.
Try this edited version:
@echo off
REM ***************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed
REM * WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I installed composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM ***************************************************************
if not defined pathBak set "pathBak=%PATH%"
set "baseWamp=C:wamp64"
set "defaultPHPver=7.1.26"
set "composerInstalled=%appData%composer"
set "phpFolder=binphpphp"
if "%~1" == "" (
set "phpVer=%baseWamp%%phpFolder%%defaultPHPver%"
) else if "%~1" == "dir" (
for /d %%A in ("%baseWamp%%phpFolder%*") do echo %%~nxA
goto :end
) else (
set "phpVer=%baseWamp%%phpFolder%%~1"
)
set "PATH=%pathBak%;%phpVer%"
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
if exist "%phpVer%pear" (
set "PHP_PEAR_SYSCONF_DIR=%phpVer%"
set "PHP_PEAR_INSTALL_DIR=%phpVer%pear"
set "PHP_PEAR_DOC_DIR=%phpVer%docs"
set "PHP_PEAR_BIN_DIR=%phpVer%"
set "PHP_PEAR_DATA_DIR=%phpVer%data"
set "PHP_PEAR_PHP_BIN=%phpVer%php.exe"
set "PHP_PEAR_TEST_DIR=%phpVer%tests"
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
set "PHP_PEAR_SYSCONF_DIR="
set "PHP_PEAR_INSTALL_DIR="
set "PHP_PEAR_DOC_DIR="
set "PHP_PEAR_BIN_DIR="
set "PHP_PEAR_DATA_DIR="
set "PHP_PEAR_PHP_BIN="
set "PHP_PEAR_TEST_DIR="
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer ?
REM *
REM **************************************************************
if exist "%composerInstalled%" (
echo COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set "COMPOSER_HOME=%composerInstalled%"
set "COMPOSER_CACHE_DIR=%composerInstalled%"
set "PATH=%PATH%;%composerInstalled%"
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
:end
set "baseWamp="
set "defaultPHPver="
set "composerInstalled="
set "phpFolder="
- Used paths from your edited version.
- Your hard coded paths replaced with existing variables.
%phpFolder%
changed to relative path, which appended to%baseWamp%
in usage (like unedited version).- Composer path changed to
%appData%composer
which should match your hard coded path. - Fixed paths in Pear section by removing the leading
%baseWamp%binphpphp
. - Undefine Pear variables if not exist in selected PHP version.
- Added
%pathBak%
to store originalPATH
value, so the originalPATH
value can be reused if the script is run again in the same session. - Added argument
dir
. Will list the folders names so you can see
what versions are available.
Awesome. Thank you. It isset phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can typephppath ANYTHING
and the output is the same if I put what should be a command of likephppath 5.6.40
orphppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straightphpver
variable of using simplyset phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.
– Brian Bruman
Mar 28 at 5:18
That works for its particular instance. I can open two tabs in cmder and in one console typephppath 5.6.40
in one andphppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point ofdefaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...
– Brian Bruman
Mar 28 at 5:36
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
1. Thanks, 2nd path it is. 2.defaultPHPver
is set at7.1.26
, then the default folder isphp7.1.26
. if you pass an argument i.ephppath.cmd 7.1.100
, then the folder isphp7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. Nosetlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.
– michael_heath
Mar 28 at 6:37
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in whichphp.exe
found inpath
would be the 1st one found, which is most probably from the 1st script run.
– michael_heath
Mar 28 at 7:00
|
show 3 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387799%2fproper-way-to-cli-php-within-wamp-wamp64-while-switching-between-multiple-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In line 20 of unedited:
set phpver=%baseWamp%%phpFolder%%1
compared to line 28 of edited:
set phpver=C:wamp64binphpphp
The %1
is the variable that contains the value of the 1st script argument.
The edited version is missing %1
so it does not change version,
but rather uses the fixed path. This may be your main issue.
Try this edited version:
@echo off
REM ***************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed
REM * WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I installed composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM ***************************************************************
if not defined pathBak set "pathBak=%PATH%"
set "baseWamp=C:wamp64"
set "defaultPHPver=7.1.26"
set "composerInstalled=%appData%composer"
set "phpFolder=binphpphp"
if "%~1" == "" (
set "phpVer=%baseWamp%%phpFolder%%defaultPHPver%"
) else if "%~1" == "dir" (
for /d %%A in ("%baseWamp%%phpFolder%*") do echo %%~nxA
goto :end
) else (
set "phpVer=%baseWamp%%phpFolder%%~1"
)
set "PATH=%pathBak%;%phpVer%"
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
if exist "%phpVer%pear" (
set "PHP_PEAR_SYSCONF_DIR=%phpVer%"
set "PHP_PEAR_INSTALL_DIR=%phpVer%pear"
set "PHP_PEAR_DOC_DIR=%phpVer%docs"
set "PHP_PEAR_BIN_DIR=%phpVer%"
set "PHP_PEAR_DATA_DIR=%phpVer%data"
set "PHP_PEAR_PHP_BIN=%phpVer%php.exe"
set "PHP_PEAR_TEST_DIR=%phpVer%tests"
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
set "PHP_PEAR_SYSCONF_DIR="
set "PHP_PEAR_INSTALL_DIR="
set "PHP_PEAR_DOC_DIR="
set "PHP_PEAR_BIN_DIR="
set "PHP_PEAR_DATA_DIR="
set "PHP_PEAR_PHP_BIN="
set "PHP_PEAR_TEST_DIR="
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer ?
REM *
REM **************************************************************
if exist "%composerInstalled%" (
echo COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set "COMPOSER_HOME=%composerInstalled%"
set "COMPOSER_CACHE_DIR=%composerInstalled%"
set "PATH=%PATH%;%composerInstalled%"
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
:end
set "baseWamp="
set "defaultPHPver="
set "composerInstalled="
set "phpFolder="
- Used paths from your edited version.
- Your hard coded paths replaced with existing variables.
%phpFolder%
changed to relative path, which appended to%baseWamp%
in usage (like unedited version).- Composer path changed to
%appData%composer
which should match your hard coded path. - Fixed paths in Pear section by removing the leading
%baseWamp%binphpphp
. - Undefine Pear variables if not exist in selected PHP version.
- Added
%pathBak%
to store originalPATH
value, so the originalPATH
value can be reused if the script is run again in the same session. - Added argument
dir
. Will list the folders names so you can see
what versions are available.
Awesome. Thank you. It isset phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can typephppath ANYTHING
and the output is the same if I put what should be a command of likephppath 5.6.40
orphppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straightphpver
variable of using simplyset phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.
– Brian Bruman
Mar 28 at 5:18
That works for its particular instance. I can open two tabs in cmder and in one console typephppath 5.6.40
in one andphppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point ofdefaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...
– Brian Bruman
Mar 28 at 5:36
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
1. Thanks, 2nd path it is. 2.defaultPHPver
is set at7.1.26
, then the default folder isphp7.1.26
. if you pass an argument i.ephppath.cmd 7.1.100
, then the folder isphp7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. Nosetlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.
– michael_heath
Mar 28 at 6:37
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in whichphp.exe
found inpath
would be the 1st one found, which is most probably from the 1st script run.
– michael_heath
Mar 28 at 7:00
|
show 3 more comments
In line 20 of unedited:
set phpver=%baseWamp%%phpFolder%%1
compared to line 28 of edited:
set phpver=C:wamp64binphpphp
The %1
is the variable that contains the value of the 1st script argument.
The edited version is missing %1
so it does not change version,
but rather uses the fixed path. This may be your main issue.
Try this edited version:
@echo off
REM ***************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed
REM * WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I installed composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM ***************************************************************
if not defined pathBak set "pathBak=%PATH%"
set "baseWamp=C:wamp64"
set "defaultPHPver=7.1.26"
set "composerInstalled=%appData%composer"
set "phpFolder=binphpphp"
if "%~1" == "" (
set "phpVer=%baseWamp%%phpFolder%%defaultPHPver%"
) else if "%~1" == "dir" (
for /d %%A in ("%baseWamp%%phpFolder%*") do echo %%~nxA
goto :end
) else (
set "phpVer=%baseWamp%%phpFolder%%~1"
)
set "PATH=%pathBak%;%phpVer%"
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
if exist "%phpVer%pear" (
set "PHP_PEAR_SYSCONF_DIR=%phpVer%"
set "PHP_PEAR_INSTALL_DIR=%phpVer%pear"
set "PHP_PEAR_DOC_DIR=%phpVer%docs"
set "PHP_PEAR_BIN_DIR=%phpVer%"
set "PHP_PEAR_DATA_DIR=%phpVer%data"
set "PHP_PEAR_PHP_BIN=%phpVer%php.exe"
set "PHP_PEAR_TEST_DIR=%phpVer%tests"
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
set "PHP_PEAR_SYSCONF_DIR="
set "PHP_PEAR_INSTALL_DIR="
set "PHP_PEAR_DOC_DIR="
set "PHP_PEAR_BIN_DIR="
set "PHP_PEAR_DATA_DIR="
set "PHP_PEAR_PHP_BIN="
set "PHP_PEAR_TEST_DIR="
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer ?
REM *
REM **************************************************************
if exist "%composerInstalled%" (
echo COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set "COMPOSER_HOME=%composerInstalled%"
set "COMPOSER_CACHE_DIR=%composerInstalled%"
set "PATH=%PATH%;%composerInstalled%"
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
:end
set "baseWamp="
set "defaultPHPver="
set "composerInstalled="
set "phpFolder="
- Used paths from your edited version.
- Your hard coded paths replaced with existing variables.
%phpFolder%
changed to relative path, which appended to%baseWamp%
in usage (like unedited version).- Composer path changed to
%appData%composer
which should match your hard coded path. - Fixed paths in Pear section by removing the leading
%baseWamp%binphpphp
. - Undefine Pear variables if not exist in selected PHP version.
- Added
%pathBak%
to store originalPATH
value, so the originalPATH
value can be reused if the script is run again in the same session. - Added argument
dir
. Will list the folders names so you can see
what versions are available.
Awesome. Thank you. It isset phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can typephppath ANYTHING
and the output is the same if I put what should be a command of likephppath 5.6.40
orphppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straightphpver
variable of using simplyset phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.
– Brian Bruman
Mar 28 at 5:18
That works for its particular instance. I can open two tabs in cmder and in one console typephppath 5.6.40
in one andphppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point ofdefaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...
– Brian Bruman
Mar 28 at 5:36
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
1. Thanks, 2nd path it is. 2.defaultPHPver
is set at7.1.26
, then the default folder isphp7.1.26
. if you pass an argument i.ephppath.cmd 7.1.100
, then the folder isphp7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. Nosetlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.
– michael_heath
Mar 28 at 6:37
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in whichphp.exe
found inpath
would be the 1st one found, which is most probably from the 1st script run.
– michael_heath
Mar 28 at 7:00
|
show 3 more comments
In line 20 of unedited:
set phpver=%baseWamp%%phpFolder%%1
compared to line 28 of edited:
set phpver=C:wamp64binphpphp
The %1
is the variable that contains the value of the 1st script argument.
The edited version is missing %1
so it does not change version,
but rather uses the fixed path. This may be your main issue.
Try this edited version:
@echo off
REM ***************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed
REM * WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I installed composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM ***************************************************************
if not defined pathBak set "pathBak=%PATH%"
set "baseWamp=C:wamp64"
set "defaultPHPver=7.1.26"
set "composerInstalled=%appData%composer"
set "phpFolder=binphpphp"
if "%~1" == "" (
set "phpVer=%baseWamp%%phpFolder%%defaultPHPver%"
) else if "%~1" == "dir" (
for /d %%A in ("%baseWamp%%phpFolder%*") do echo %%~nxA
goto :end
) else (
set "phpVer=%baseWamp%%phpFolder%%~1"
)
set "PATH=%pathBak%;%phpVer%"
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
if exist "%phpVer%pear" (
set "PHP_PEAR_SYSCONF_DIR=%phpVer%"
set "PHP_PEAR_INSTALL_DIR=%phpVer%pear"
set "PHP_PEAR_DOC_DIR=%phpVer%docs"
set "PHP_PEAR_BIN_DIR=%phpVer%"
set "PHP_PEAR_DATA_DIR=%phpVer%data"
set "PHP_PEAR_PHP_BIN=%phpVer%php.exe"
set "PHP_PEAR_TEST_DIR=%phpVer%tests"
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
set "PHP_PEAR_SYSCONF_DIR="
set "PHP_PEAR_INSTALL_DIR="
set "PHP_PEAR_DOC_DIR="
set "PHP_PEAR_BIN_DIR="
set "PHP_PEAR_DATA_DIR="
set "PHP_PEAR_PHP_BIN="
set "PHP_PEAR_TEST_DIR="
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer ?
REM *
REM **************************************************************
if exist "%composerInstalled%" (
echo COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set "COMPOSER_HOME=%composerInstalled%"
set "COMPOSER_CACHE_DIR=%composerInstalled%"
set "PATH=%PATH%;%composerInstalled%"
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
:end
set "baseWamp="
set "defaultPHPver="
set "composerInstalled="
set "phpFolder="
- Used paths from your edited version.
- Your hard coded paths replaced with existing variables.
%phpFolder%
changed to relative path, which appended to%baseWamp%
in usage (like unedited version).- Composer path changed to
%appData%composer
which should match your hard coded path. - Fixed paths in Pear section by removing the leading
%baseWamp%binphpphp
. - Undefine Pear variables if not exist in selected PHP version.
- Added
%pathBak%
to store originalPATH
value, so the originalPATH
value can be reused if the script is run again in the same session. - Added argument
dir
. Will list the folders names so you can see
what versions are available.
In line 20 of unedited:
set phpver=%baseWamp%%phpFolder%%1
compared to line 28 of edited:
set phpver=C:wamp64binphpphp
The %1
is the variable that contains the value of the 1st script argument.
The edited version is missing %1
so it does not change version,
but rather uses the fixed path. This may be your main issue.
Try this edited version:
@echo off
REM ***************************************************************
REM * PLACE This file in a folder that is already on your PATH
REM * Or just put it in your C:Windows folder as that is on the
REM * Search path by default
REM * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
REM * EDIT THE NEXT 3 Parameters to fit your installed WAMPServer
REM * for example I installed WAMPServer on the D: drive you may
REM * have used C:
REM * - baseWamp : is the drive and folder where you installed
REM * WAMPServer
REM * - defaultPHPver : is the version of PHP that will be pathed
REM * if no Parameter is put on the bat file
REM * - composerInstalled : Where I installed composerInstalled
REM * - phpFolder : The folder structure that contains the Multiple
REM * possible version of PHP I have installed
REM ***************************************************************
if not defined pathBak set "pathBak=%PATH%"
set "baseWamp=C:wamp64"
set "defaultPHPver=7.1.26"
set "composerInstalled=%appData%composer"
set "phpFolder=binphpphp"
if "%~1" == "" (
set "phpVer=%baseWamp%%phpFolder%%defaultPHPver%"
) else if "%~1" == "dir" (
for /d %%A in ("%baseWamp%%phpFolder%*") do echo %%~nxA
goto :end
) else (
set "phpVer=%baseWamp%%phpFolder%%~1"
)
set "PATH=%pathBak%;%phpVer%"
php -v
echo ---------------------------------------------------------------
REM IF PEAR IS INSTALLED IN THIS VERSION OF PHP
if exist "%phpVer%pear" (
set "PHP_PEAR_SYSCONF_DIR=%phpVer%"
set "PHP_PEAR_INSTALL_DIR=%phpVer%pear"
set "PHP_PEAR_DOC_DIR=%phpVer%docs"
set "PHP_PEAR_BIN_DIR=%phpVer%"
set "PHP_PEAR_DATA_DIR=%phpVer%data"
set "PHP_PEAR_PHP_BIN=%phpVer%php.exe"
set "PHP_PEAR_TEST_DIR=%phpVer%tests"
echo PEAR INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
) else (
set "PHP_PEAR_SYSCONF_DIR="
set "PHP_PEAR_INSTALL_DIR="
set "PHP_PEAR_DOC_DIR="
set "PHP_PEAR_BIN_DIR="
set "PHP_PEAR_DATA_DIR="
set "PHP_PEAR_PHP_BIN="
set "PHP_PEAR_TEST_DIR="
echo PEAR DOES NOT EXIST IN THIS VERSION OF php
echo ---------------------------------------------------------------
)
REM IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM **************************************************************
REM * IF A GLOBAL COMPOSER EXISTS ADD THAT TOO
REM *
REM * This assumes that composer is installed in /wamp/composer ?
REM *
REM **************************************************************
if exist "%composerInstalled%" (
echo COMPOSER INCLUDED IN THIS CONFIG
echo ---------------------------------------------------------------
set "COMPOSER_HOME=%composerInstalled%"
set "COMPOSER_CACHE_DIR=%composerInstalled%"
set "PATH=%PATH%;%composerInstalled%"
rem echo TO UPDATE COMPOSER do > composer self-update
echo ---------------------------------------------------------------
) else (
echo ---------------------------------------------------------------
echo COMPOSER IS NOT INSTALLED
echo ---------------------------------------------------------------
)
:end
set "baseWamp="
set "defaultPHPver="
set "composerInstalled="
set "phpFolder="
- Used paths from your edited version.
- Your hard coded paths replaced with existing variables.
%phpFolder%
changed to relative path, which appended to%baseWamp%
in usage (like unedited version).- Composer path changed to
%appData%composer
which should match your hard coded path. - Fixed paths in Pear section by removing the leading
%baseWamp%binphpphp
. - Undefine Pear variables if not exist in selected PHP version.
- Added
%pathBak%
to store originalPATH
value, so the originalPATH
value can be reused if the script is run again in the same session. - Added argument
dir
. Will list the folders names so you can see
what versions are available.
edited Mar 29 at 0:56
answered Mar 28 at 2:39
michael_heathmichael_heath
3,5772 gold badges7 silver badges20 bronze badges
3,5772 gold badges7 silver badges20 bronze badges
Awesome. Thank you. It isset phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can typephppath ANYTHING
and the output is the same if I put what should be a command of likephppath 5.6.40
orphppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straightphpver
variable of using simplyset phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.
– Brian Bruman
Mar 28 at 5:18
That works for its particular instance. I can open two tabs in cmder and in one console typephppath 5.6.40
in one andphppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point ofdefaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...
– Brian Bruman
Mar 28 at 5:36
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
1. Thanks, 2nd path it is. 2.defaultPHPver
is set at7.1.26
, then the default folder isphp7.1.26
. if you pass an argument i.ephppath.cmd 7.1.100
, then the folder isphp7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. Nosetlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.
– michael_heath
Mar 28 at 6:37
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in whichphp.exe
found inpath
would be the 1st one found, which is most probably from the 1st script run.
– michael_heath
Mar 28 at 7:00
|
show 3 more comments
Awesome. Thank you. It isset phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can typephppath ANYTHING
and the output is the same if I put what should be a command of likephppath 5.6.40
orphppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straightphpver
variable of using simplyset phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.
– Brian Bruman
Mar 28 at 5:18
That works for its particular instance. I can open two tabs in cmder and in one console typephppath 5.6.40
in one andphppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point ofdefaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...
– Brian Bruman
Mar 28 at 5:36
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
1. Thanks, 2nd path it is. 2.defaultPHPver
is set at7.1.26
, then the default folder isphp7.1.26
. if you pass an argument i.ephppath.cmd 7.1.100
, then the folder isphp7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. Nosetlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.
– michael_heath
Mar 28 at 6:37
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in whichphp.exe
found inpath
would be the 1st one found, which is most probably from the 1st script run.
– michael_heath
Mar 28 at 7:00
Awesome. Thank you. It is
set phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can type phppath ANYTHING
and the output is the same if I put what should be a command of like phppath 5.6.40
or phppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straight phpver
variable of using simply set phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.– Brian Bruman
Mar 28 at 5:18
Awesome. Thank you. It is
set phpFolder=binphpphp
you're right on second. Looks much more optimized and robust, but still failing to change php version. In fact I can type phppath ANYTHING
and the output is the same if I put what should be a command of like phppath 5.6.40
or phppath 7.0.33
. I'm going to see what happens when I remove the if else statement and just have a straight phpver
variable of using simply set phpver=%baseWamp%%phpFolder%%1
. Assuming this will require my input of a version or fail.– Brian Bruman
Mar 28 at 5:18
That works for its particular instance. I can open two tabs in cmder and in one console type
phppath 5.6.40
in one and phppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point of defaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...– Brian Bruman
Mar 28 at 5:36
That works for its particular instance. I can open two tabs in cmder and in one console type
phppath 5.6.40
in one and phppath 7.0.3.3
in another, and actually switch between the tabs and use the different versions simultaneously. That's pretty cool. But that being said, I also wonder what is/was the point of defaultPHPver
in the original script. Doing it this way I omit that entirely. In fact, if I include a default version, I'm entirely stuck to that one and cannot change otherwise (one version per instance). I'm not familiar with batch-files whatsoever, is there a good ...– Brian Bruman
Mar 28 at 5:36
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
... workaround that you may know that could kill the current process, so that its not stuck on whatever version it's pointed too? That might be one workaround, although I'm still perplexed as to how the first code operates properly. Could be that linux systems act different than Windows in this regard? Edit: Actually, that can't be right. I just re-realized what the W in WAMP stands for. They must be both Windows versions. Perhaps Windows 10 works differently, then?
– Brian Bruman
Mar 28 at 5:37
1. Thanks, 2nd path it is. 2.
defaultPHPver
is set at 7.1.26
, then the default folder is php7.1.26
. if you pass an argument i.e phppath.cmd 7.1.100
, then the folder is php7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. No setlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.– michael_heath
Mar 28 at 6:37
1. Thanks, 2nd path it is. 2.
defaultPHPver
is set at 7.1.26
, then the default folder is php7.1.26
. if you pass an argument i.e phppath.cmd 7.1.100
, then the folder is php7.1.100
. So you need to have folders named as such to match. The script sets the environment in that session. No setlocal
is used so variables are not destroyed at end of the run of the script. 3. I see no signs of where Linux or where Windows 10 applies.– michael_heath
Mar 28 at 6:37
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in which
php.exe
found in path
would be the 1st one found, which is most probably from the 1st script run.– michael_heath
Mar 28 at 7:00
The script should run and exit. I am not sure what process that you are referring to that needs killing. batch-file is for Windows, Indeed. Running the script a 2nd time in the same session would add to the path variable again in which
php.exe
found in path
would be the 1st one found, which is most probably from the 1st script run.– michael_heath
Mar 28 at 7:00
|
show 3 more comments
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387799%2fproper-way-to-cli-php-within-wamp-wamp64-while-switching-between-multiple-php%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown