AlternatePHP is a batch file for Windows environments that can make different versions of php available. It is inspired by phpenv / rbenv which is available on other operating systems.
Goals:
- Simply execute your script with another version of php
- Quick "install" of a new version
Current default PHP version: 7.0.15
php -v
orphp <script.php> <arguments>
calls current default php versionphp <version> -v
orphp <version> <script.php> <arguments>
calls the same on given php version (format: e.g.5.6.27
)php xdebug -v
orphp xdebug <script.php> <arguments>
calls current default php version with xdebugphp <version> xdebug -v
orphp <version> xdebug <script.php> <arguments>
calls the same on given php version with xdebug
php --version
andphp -v
outputs version AlternatePHP before original outputphp help
andphp /?
outputs help information for AlternatePHPphp install
installs current default php versionphp install <version>
installs given php version (format: e.g.5.6.27
)php versions
lists all currently installed versionsphp global <version>
configure default version (like phpenv)php rename <version> <version>
for support custom version aliasphp license
for output of LICENSEphp self-update
download latest release of AlternatePHP from GitHubphp [<version>] [xdebug] composer <command>
run latest composer.phar
php local <version>
configure version for current folder (like phpenv)php configure <version> ...
is planned for some php.ini modifications (interface/arguments not planned yet)php enable-xdebug <version>
directly add correct php_xdebug.dll to given version and add extension to php.iniphp disable-xdebug <version>
remove extension from php.ini
- bitsadmin (for downloading binaries from https://windows.php.net/download)
- unzip (if not available yet, please download from https://gnuwin32.sourceforge.net/packages/unzip.htm and put unzip.exe to your PATH)
There should be no global installed PHP-Environment-Variables (like PHPRC) or other php.exe within PATH
It is recommended to add AlternatePHP (directory where php.bat is located) to your PATH
- Download zip (latest release or from current master)
- unzip to a folder
- optional: put unzip.exe to the same folder, if not available on the system
- add that folder to path
- optional: use
php global <version>
to specify your version (if not set, the default is used) - call
php install
to download and unzip that php version
It is recommended to set a global version, because after next update another php version can be set as default.
You should use php self-update
(available with v1.1) to update your installation.
Without self-update: download zip and unzip over existing installation.
$ git clone https://github.com/glady/AlternatePHP.git
$ cd AlternatePHP
$ php versions
$ php help
[...]
$ php install
[... downloads default php version ...]
[... unzips downloaded version ...]
[... copy php.ini-production to php.ini ...]
$ php versions
7.0.12
$ php -v
glady/AlternatePHP v1.0.0
PHP 7.0.12 (cli) (built: Oct 13 2016 10:47:49) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
$ php install 5.6.27
[... downloads php 5.6.27 ...]
[... unzips downloaded version ...]
[... copy php.ini-production to php.ini ...]
$ php versions
5.6.27 7.0.12
$ php -v
glady/AlternatePHP v1.0.0
PHP 7.0.12 (cli) (built: Oct 13 2016 10:47:49) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
$ php 5.6.27 -v
glady/AlternatePHP v1.0.0
PHP 5.6.27 (cli) (built: Oct 14 2016 10:23:05)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
$ php 7.0.12 -v
glady/AlternatePHP v1.0.0
PHP 7.0.12 (cli) (built: Oct 13 2016 10:47:49) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
When php_xdebug.dll (named like this) is available within ext
folder of current php folder, then a script can be called
by php xdebug script.php
for loading xdebug within that process.
$ php xdebug -v
glady/AlternatePHP v1.0.0
PHP 7.0.12 (cli) (built: Oct 13 2016 10:47:49) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
$ php 7.0.12 xdebug -v
glady/AlternatePHP v1.0.0
PHP 7.0.12 (cli) (built: Oct 13 2016 10:47:49) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans