- Introduction
- About phpvm
- Installation
- Usage
- Running Tests
- Uninstallation
- Troubleshooting
- Maintainers
- License
- Disclaimer
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 install 8.1
Now using PHP v8.1.1
$ php -v
PHP 8.1.1
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 PHP versions.
- Manage global PHP settings and extensions.
- Install PHP versions via package managers like
apt
orbrew
, or from source. - Auto-detect
.phpvmrc
files to switch PHP versions based on project configuration. - Supports Homebrew and Linux package managers, or installation from source for more advanced setups.
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. You can also install PHP using a package manager:
phpvm install --package-manager 7.4
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
.
To set the default PHP version for new shells, use:
phpvm alias default 8.0
This will ensure that PHP 8.0 is used as the default version whenever a new shell is opened.
To use the system-installed version of PHP:
phpvm use system
To use a mirror of PHP binaries, set the PHPVM_MIRROR
environment variable:
export PHPVM_MIRROR=https://php-mirror-url.com
phpvm install 8.0
If a .phpvmrc
file is present in the directory, phpvm
will automatically switch to the PHP version specified in the file. This allows seamless version switching when working on different projects that require different PHP versions.
To set up the .phpvmrc
file for your project, create a file with the following content:
# .phpvmrc
8.0.8
When navigating to a directory with this file, phpvm
will automatically switch to the specified PHP version.
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.
We recommend reviewing the source code, running tests, and using the tool in a controlled environment before deploying it in production settings. Contributions are always welcome, but please ensure any changes are well-tested and follow best practices.
If you encounter issues or need assistance, please open an issue on our GitHub repository, but note that support is offered as time and resources allow.