phpvm is a fast, cross-platform PHP version manager written in Rust that lets you install, switch, and manage multiple PHP versions per project or globally. It provides lightweight shims and shell integration for seamless PATH management, supports prebuilt binaries and optional source builds, and includes commands for listing, installing/uninstalling, aliasing, executing with a specific version, and diagnosing your setup (doctor) on macOS, Linux, and Windows.
- 🚀 Fast: Built in Rust for maximum performance
- 🎯 Simple: NVM-style commands that PHP developers know and love
- 🔄 Cross-platform: Works on macOS, Linux, and Windows
- 📦 Prebuilt binaries: No compilation required
- 🛠️ Source builds: Install PHP from official source tarballs
- 🎨 Shell integration: Automatic PATH management
- 💾 Caching: Smart caching for faster installs
- 🔧 Doctor: Diagnose and fix common issues
Bash/Zsh:
curl -fsSL https://raw.githubusercontent.com/olashina201/php-vm/main/scripts/install.sh | bashUsing wget:
wget -qO- https://raw.githubusercontent.com/olashina201/php-vm/main/scripts/install.sh | bashPin a specific version:
PHPVM_VERSION=v0.1.0 \
bash -c "$(curl -fsSL https://raw.githubusercontent.com/olashina201/php-vm/main/scripts/install.sh)"- Download the latest release for your platform from GitHub Releases
- Extract the archive
- Move the
phpvmbinary to a directory in your PATH (e.g.,/usr/local/bin) - Run
phpvm initto set up shell integration
git clone https://github.com/olashina201/php-vm.git
cd php-vm
cargo build --release
sudo cp target/release/phpvm /usr/local/bin/After installation, restart your shell or run:
export PATH="$HOME/.phpvm/bin:$PATH"
phpvm doctorInitialize phpvm for your shell:
# Auto-detect shell
phpvm init
# Specify shell
phpvm init --shell bash
phpvm init --shell zsh
phpvm init --shell fish
phpvm init --shell powershell # WindowsList available PHP versions:
# List all available versions
phpvm list-remote
# List versions for a specific major version
phpvm list-remote --major 8.2
phpvm list-remote --major 8.3List installed versions:
phpvm listInstall PHP:
# Install latest 8.3.x
phpvm install 8.3
# Install specific version
phpvm install 8.3.11
# Install from source (Unix only)
phpvm install 8.3.11 --from source
# Install thread-safe build (Windows)
phpvm install 8.3.11 --tsUninstall PHP:
phpvm uninstall 8.3.11Use a version for current shell session:
# Use specific version
phpvm use 8.3.11
# Use latest 8.3.x
phpvm use 8.3Set global default version:
phpvm global 8.3.11Set local version for a project:
# In your project directory
phpvm local 8.3.11
# Creates .php-version fileRun commands with specific PHP version:
# Run PHP with specific version
phpvm exec 8.3.11 php --version
# Run Composer with specific PHP version
phpvm exec 8.3.11 composer install
# Run any command
phpvm exec 8.3.11 php artisan migrateFind PHP binary path:
# Find current PHP binary
phpvm which php
# Find specific program
phpvm which composer
phpvm which peclCreate version aliases:
# Create alias
phpvm alias latest 8.3.11
phpvm alias stable 8.2.25
# List aliases
phpvm alias
# Delete alias
phpvm alias --delete latestUse aliases:
# Use alias
phpvm use latest
phpvm global stableClean up cache:
phpvm cache pruneUpdate phpvm itself:
phpvm self-updateDiagnose issues:
phpvm doctorThis will check:
- Installation paths
- Shell integration
- Required dependencies
- Common configuration issues
# 1. Install phpvm
curl -fsSL https://raw.githubusercontent.com/olashina201/php-vm/main/scripts/install.sh | bash
# 2. Restart shell or source profile
source ~/.bashrc # or ~/.zshrc
# 3. Check installation
phpvm doctor
# 4. List available versions
phpvm list-remote --major 8.3
# 5. Install PHP 8.3.11
phpvm install 8.3.11
# 6. Set as global default
phpvm global 8.3.11
# 7. Verify installation
php --version
# 8. Create project with specific version
mkdir my-project
cd my-project
phpvm local 8.2.25
echo "<?php phpinfo(); ?>" > index.php
# 9. Run with project's PHP version
php index.php# Switch between PHP versions for different projects
cd project-a
phpvm local 8.3.11
php artisan serve
cd ../project-b
phpvm local 8.2.25
composer install
phpunit
# Use specific version for one command
phpvm exec 8.1.30 php -m | grep -i curl# In your CI script
phpvm install 8.3.11
phpvm use 8.3.11
composer install
phpunitPHPVM_ROOT: Override default installation directory (default:~/.phpvm)PHPVM_CACHE_DIR: Override cache directory (default:~/.phpvm/cache)
- Installation root:
~/.phpvm/ - PHP versions:
~/.phpvm/versions/ - Shims:
~/.phpvm/shims/ - Cache:
~/.phpvm/cache/ - Global version:
~/.phpvm/global - Local version:
.php-version(in project directory)
Add to your ~/.bashrc or ~/.zshrc:
export PATH="$HOME/.phpvm/bin:$PATH"
eval "$(phpvm init)"Add to your ~/.config/fish/config.fish:
set -gx PATH $HOME/.phpvm/bin $PATH
phpvm init | sourceAdd to your PowerShell profile:
# Run once to get the import command
phpvm init powershell
# Then add the printed Import-Module command to your profilecurlorwgetfor downloadingtarfor extracting archivesgccandmakefor source builds- Standard build tools (
autoconf,libtool, etc.)
- PowerShell 5.1+ or PowerShell Core
- Visual Studio Build Tools (for source builds)
"phpvm: command not found"
# Add to PATH
export PATH="$HOME/.phpvm/bin:$PATH"
# Or restart your shell"Permission denied"
# Fix permissions
chmod +x ~/.phpvm/bin/phpvmShell integration not working
# Re-initialize
phpvm init
# Or manually add to your shell config
eval "$(phpvm init)"PHP not found after install
# Check installation
phpvm doctor
# Reinstall shims
phpvm use 8.3.11We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/olashina201/php-vm.git
cd php-vm
cargo build
cargo testLicensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.