A fast, cross-platform PHP version manager inspired by nvm. Install PHP from source, manage multiple versions, and switch between them seamlessly.
- Install PHP from source with configurable build profiles (minimal, common, full)
- Switch PHP versions instantly via symlinks
- Manage php.ini settings with profiles (development, production)
- Install PECL extensions with automatic phpize/configure/make
- Shell integration for bash, zsh, fish, and PowerShell
- Cross-platform support for Linux, macOS, and Windows
Linux/macOS:
curl -fsSL https://raw.githubusercontent.com/hightemp/phvm/main/scripts/install.sh | bashWindows (PowerShell):
iwr -useb https://raw.githubusercontent.com/hightemp/phvm/main/scripts/install.ps1 | iexAdd to your shell profile:
Bash (~/.bashrc):
eval "$(~/.phvm/bin/phvm init bash)"Zsh (~/.zshrc):
eval "$(~/.phvm/bin/phvm init zsh)"Fish (~/.config/fish/config.fish):
~/.phvm/bin/phvm init fish | sourcePowerShell ($PROFILE):
Invoke-Expression (& ~/.phvm/bin/phvm init powershell)# Check system dependencies phvm doctor # List available PHP versions phvm ls-remote # Install a PHP version phvm install 8.3 # Install specific version with build profile phvm install 8.3.15 --profile full # List installed versions phvm ls # Switch to a version phvm use 8.3.15 # Set default version phvm alias default 8.3.15 # Show current version phvm current| Command | Description |
|---|---|
phvm install <version> | Install a PHP version |
phvm uninstall <version> | Remove an installed version |
phvm use <version> | Switch to a version |
phvm current | Show active version |
phvm ls | List installed versions |
phvm ls-remote | List available versions |
| Command | Description |
|---|---|
phvm alias <name> <version> | Create an alias |
phvm alias rm <name> | Remove an alias |
phvm alias ls | List all aliases |
| Command | Description |
|---|---|
phvm ext install <name> | Install PECL extension |
phvm ext remove <name> | Remove extension |
phvm ext enable <name> | Enable extension |
phvm ext disable <name> | Disable extension |
phvm ext ls | List installed extensions |
| Command | Description |
|---|---|
phvm ini get <key> | Get php.ini value |
phvm ini set <key> <value> | Set php.ini value |
phvm ini profile <name> | Apply ini profile (development/production) |
phvm ini edit | Open php.ini in editor |
| Command | Description |
|---|---|
phvm doctor | Check build dependencies |
phvm composer install | Install Composer |
phvm cache clean | Clear download cache |
phvm init <shell> | Print shell init script |
When installing PHP, you can choose a build profile:
- minimal - Core PHP only, smallest footprint
- common - Common extensions (curl, json, mbstring, openssl, etc.)
- full - All available extensions
# Install with minimal profile phvm install 8.3 --profile minimal # Install with full profile phvm install 8.3 --profile fullSwitch between development and production configurations:
# Apply development settings (display_errors=On, etc.) phvm ini profile development # Apply production settings (display_errors=Off, etc.) phvm ini profile production~/.phvm/ ├── bin/ # phvm binary ├── versions/ │ └── php/ │ ├── 8.3.15/ # Installed PHP version │ └── 8.2.27/ ├── current -> versions/php/8.3.15 # Active version symlink ├── alias/ │ └── default # Alias files ├── cache/ │ └── downloads/ # Downloaded tarballs ├── config/ │ └── config.toml # phvm configuration └── logs/ # Build logs Create ~/.phvm/config/config.toml:
# Default build profile default_profile = "common" # Parallel make jobs jobs = 4 # Verify GPG signatures verify_gpg = true # Custom configure flags [configure] flags = ["--with-pear"]- Go 1.21 or later
- Git
git clone https://github.com/hightemp/phvm.git cd phvm make deps make build# Install to GOBIN make install # Or install to ~/.phvm/bin make install-local# Run tests make test # Run linter make lint # Format code make fmtBefore installing PHP, ensure you have the required build dependencies:
# Check what's needed phvm doctorsudo apt-get install -y \ build-essential \ autoconf \ bison \ re2c \ libxml2-dev \ libsqlite3-dev \ libcurl4-openssl-dev \ libonig-dev \ libpng-dev \ libjpeg-dev \ libfreetype6-dev \ libzip-dev \ libssl-devbrew install \ autoconf \ bison \ re2c \ libxml2 \ sqlite \ curl \ oniguruma \ libpng \ libjpeg \ freetype \ libzip \ openssl@3sudo dnf install -y \ gcc \ gcc-c++ \ make \ autoconf \ bison \ re2c \ libxml2-devel \ sqlite-devel \ libcurl-devel \ oniguruma-devel \ libpng-devel \ libjpeg-devel \ freetype-devel \ libzip-devel \ openssl-devel| Variable | Description | Default |
|---|---|---|
PHVM_DIR | phvm installation directory | ~/.phvm |
PHVM_VERSION | Version to install (installer) | latest |
Run phvm doctor to identify missing dependencies, then install them using your package manager.
Ensure ~/.phvm is owned by your user:
sudo chown -R $USER:$USER ~/.phvmMake sure you've added the shell init script to your profile and restarted your shell.
Check that phpize is available and development headers are installed:
phvm doctorContributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE for details.