Run PHP. Any version. Without install.
Important note: This script is designed to run on Linux and requires docker to be installed.
Get the latest release from github...
# $BINDIR may be any of the $PATH directories, eg: ~/bin, /usr/local/bin, etc...
curl -Lo $BINDIR/php https://github.com/yannoff/p-a-w/releases/latest/download/php
# Make the main script executable
chmod +x $BINDIR/php...add support for the desired php versions
ln -s $BINDIR/php $BINDIR/php5.6
ln -s $BINDIR/php $BINDIR/php7.4
ln -s $BINDIR/php $BINDIR/php8.0..and that's it !
Based on the multi-call binary principle (as the well-known BusyBox project) , each php<version> (1) file is just a symlink pointing to the main php entrypoint script: PHP version is deduced from the invoked filename.
(1) If invoked without any suffix, the default version will be used: either the
PHP_VERSIONenv var (if set), the latest GA release (currently 8.5) otherwise.
Hence, adding support for a PHP version is dead-simple: just create a new php<version> (2) symlink to the main php script.
For example:
# Assume ~/bin is in the $PATH system-wide environment variable
~/bin $ ln -s php php7.4
# Now PHP 7.4 can be accessed from everywhere in the system
~/bin $ cd /some/other/path
/some/other/path $ php7.4 --version
PHP 7.4.28 (cli) (built: Mar 29 2022 03:52:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies(2) Version must be one of the following:
5.5,5.6,7.0,7.1,7.2,7.3,7.4,8.0,8.1,8.2,8.3,8.4,8.5
The following examples are given assuming that:
- The
phpmulti-call script is in one of the$PATHdirs - A symlink to it has been created for each php version
Open a PHP 8.0 interactive shell in the current directory
php8.0 -aOpen a PHP 8.2 container-secluded bash session, with access to the current directory
php8.2The following environment variables allow to fine-tune the PAW script behaviour
| Name | Description | Fallback value |
|---|---|---|
PHP_VERSION |
The default version to use for PHP |
8.5 |
PAW_IMAGE |
PHP docker image to leverage | yannoff/php-fpm (3) |
PAW_DEBUG |
If set, turn on debug mode | - |
(3) Based on Alpine, this image uses
musl-libc, which implementation differs fromglibcon some aspects.
Licensed under the MIT License.