phpvm
is a PHP Version Manager that allows you to easily install, switch between, and manage multiple PHP versions via the command line.
Example:
$ phpvm use 7.4
Now using PHP v7.4.10
$ php -v
PHP 7.4.10
$ phpvm use 8.0
Now using PHP v8.0.8
$ php -v
PHP 8.0.8
phpvm
is a version manager designed to be used on Unix-like systems, including macOS and Linux. It allows you to install and manage PHP versions, switch between them seamlessly, and work with multiple versions on your system.
- Install and use different PHP versions.
- Easily switch between installed PHP versions.
- List installed PHP versions.
- Uninstall a specific PHP version.
To install or update phpvm, run the following command using either curl
or wget
:
curl -o- https://raw.githubusercontent.com/Thavarshan/phpvm/main/bin/install.sh | bash
wget -qO- https://raw.githubusercontent.com/Thavarshan/phpvm/main/bin/install | bash
This script clones the phpvm
repository into ~/.phpvm
and attempts to add the following lines to your profile (~/.bashrc
, ~/.zshrc
, or ~/.profile
):
export PHPVM_DIR="$HOME/.phpvm"
export PATH="$HOME/.local/bin:$PATH"
To verify that phpvm
has been installed, run the following command:
command -v phpvm
This should output phpvm
if the installation was successful.
To manually install phpvm
, clone the repository:
git clone https://github.com/Thavarshan/phpvm.git ~/.phpvm
Then add the following lines to your shell's profile (~/.bashrc
, ~/.zshrc
, etc.):
export PHPVM_DIR="$HOME/.phpvm"
export PATH="$HOME/.local/bin:$PATH"
To manually update phpvm
to the latest version, use the following commands:
cd ~/.phpvm
git fetch --tags origin
git checkout `git describe --abbrev=0 --tags`
To install a specific version of PHP, run:
phpvm install 8.1
This will install PHP version 8.1.
To switch between installed versions:
phpvm use 8.0
This will switch to PHP 8.0. You can verify the active version by running:
php -v
To uninstall a version of PHP:
phpvm uninstall 7.4
This will uninstall PHP 7.4 from the system.
To list the installed PHP versions:
phpvm list
This will display all the PHP versions managed by phpvm
.
You can run tests using Jest. Install the dependencies and run the following command:
npm install
npm test
This will run all tests defined for phpvm
.
To manually uninstall phpvm
, run:
rm -rf ~/.phpvm
And remove the following lines from your shell's profile:
export PHPVM_DIR="$HOME/.phpvm"
export PATH="$HOME/.local/bin:$PATH"
If you encounter any issues with phpvm
or its functionality, consider the following troubleshooting steps:
- Make sure your shell configuration file is correctly sourcing
phpvm
. - For macOS, ensure that the necessary command line tools (like Homebrew or Xcode) are installed.
- Restart your terminal after making any changes.
- Ensure you have proper permissions to install PHP versions and modify system paths.
phpvm
is maintained by Jerome Thayananthajothy.
This project is licensed under the MIT License. See LICENSE for more details.
phpvm
is an open-source tool designed to simplify PHP version management. While we strive to ensure its functionality across different platforms and configurations, we make no warranties or guarantees regarding its accuracy, completeness, reliability, or suitability for any particular purpose.
Use at your own risk. By using phpvm
, you acknowledge that the developers and contributors are not responsible for any damages or data loss resulting from the installation, configuration, or use of this tool.