- Notifications
You must be signed in to change notification settings - Fork0
mbezhanov/phpvm
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
phpvm (short for "PHP Version Manager") is a simple bash script for managing PHP versions, inspired byNVM and powered byDocker.
phpvm uses Docker images and containers to enable seamless switching between PHP versions for local development. It can also be used to build highly-customized production-ready PHP Docker images.
To installphpvm, simply downloadphpvm.sh
and put it in your path.
wget https://github.com/mbezhanov/phpvm/archive/master.zipunzip -p master.zip phpvm-master/phpvm.sh> phpvmmv phpvm /usr/local/binchmod +x /usr/local/bin/phpvm
At this point you should be able to callphpvm
from your command line.
Simply typingphpvm
in your console, without any arguments, will list all of the available commands.
To use a particular PHP version with your project, navigate to your project root, then run:
phpvm use <version>
...where<version>
can be any tag available in thePHP Official Docker Image
For example, if you'd like to run PHP 7.3.6, you can do something like:
phpvm use 7.3.6-cli-alpine
This will automatically pull the corresponding image from Docker Hub and start a new container from it, mounting your project root to/src
inside the container and installing the latest version of Composer in the process.
You can usephpvm root
to open a terminal for interacting with your container as theroot
user. This will allow you to tweak the PHP configuration, add specific extensions, or install additional Linux packages.phpvm will remember your changes and associate them with the selected PHP version. Next time you runphpvm use 7.3.6-cli-alpine
, you can count on finding the same set of configuration settings, extensions and Linux packages available.
To open a terminal for interacting with your container as the currently logged in user, you can typephpvm tty
. This is suitable for runningcomposer install
,composer update
or any other console scripts and commands related to your project, as it retains the file and directory permissions of your current user.
When you're done using your container, you can optionally typephpvm deactivate
to switch it off.