# PVM (PHP Version Manager)
[](https://github.com/WebProject-xyz/php-version-manager/actions/workflows/release.yml)
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://crates.io/crates/php-version-manager)
Native, blazing fast, zero-configuration PHP version manager for Arch Linux and other Linux/macOS environments, heavily inspired by [fnm](https://github.com/Schniz/fnm).
PVM uses pre-compiled static PHP CLI binaries from [Static PHP CLI (SPC)](https://dl.static-php.dev/) to completely bypass compilation times and library dependency hell on Linux.
## Features
- 🚀 **Blazing Fast**: Written in Rust natively. Execution means zero overhead compared to Docker wrappers.
- ✨ **Zero Configuration**: Auto-switches PHP versions based on `.php-version` files.
- 📦 **Static Binaries**: No compilation needed. The `pvm install` command instantly downloads self-contained executables with most common extensions pre-baked.
- 🧩 **Multi-Package Selection**: Pick which packages to install per version — `cli`, `fpm`, and/or `micro` (`micro.sfx`) — via an interactive MultiSelect prompt. `cli` is the default.
- 🐘 **Native Composer Support**: Works out of the box with your system's global Composer without any explicit proxy or configuration.
- 🖱️ **Interactive TUI Menus**: Run `pvm` without arguments to launch a master selection menu. Or run commands like `pvm use` / `pvm ls-remote` / `pvm uninstall` without parameters to select actions via a visual UI.
- 🏷️ **Smart Aliasing**: Install and use patches cleanly by saying `pvm install 8.4`. PVM dynamically figures out the highest patch (`8.4.18`) underneath the hood.
- 🔄 **Patch Update Check**: `pvm use 8.4` notices when a newer patch (e.g. `8.4.19`) is available and offers to install and switch in one step.
- 📝 **`.php-version` Bootstrap**: `pvm init` interactively picks a major.minor and writes `.php-version` for the current directory.
- 🗑️ **Clean Uninstall**: `pvm uninstall` (alias `rm` / `remove`) removes a version's binaries; warns when removing the active one.
- 🐚 **Multi-Shell**: Bash, Zsh, and Fish wrappers generated by `pvm env`, with concurrency-safe per-PID env files locked via `fs4`.
- ⚡ **Cached Cloud Resolution**: Quickly check for new versions on `dl.static-php.dev` under lightning-fast 24-hour JSON caching.
## Installation
We provide an automatic install script that detects your platform exactly like `fnm` and downloads the pre-compiled native `pvm` binary directly from GitHub Releases into `~/.local/share/pvm/bin`, and then instructs you how to append the hook to your profile.
**Using a script (macOS/Linux)**
```bash
**Building from Source**
If you prefer to compile the application from scratch using Rust:
```bash
git clone git@github.com:WebProject-xyz/php-version-manager.git
cd php-version-manager
chmod +x build.sh
./build.sh
```
## Usage
```bash
# Enter the master interactive TUI menu
pvm
# Install a specific PHP version (by minor alias or fully-qualified).
# Opens a MultiSelect to pick packages: cli (default), fpm, micro.
pvm install 8.4 # alias: pvm i 8.4
# Install the absolute latest version available
pvm install latest
# Use a version in the current shell.
# Auto-prompts to install + switch if a newer patch exists upstream.
pvm use 8.4
# List all local installed versions alongside their specific aliases
pvm ls # alias for: pvm list
# Interactively view and install available cloud versions
pvm ls-remote # alias: pvm list-remote
# Print the currently active PHP version
pvm current
# Remove an installed version (interactive picker if no arg).
pvm uninstall 8.3 # aliases: pvm rm 8.3 / pvm remove 8.3
# Write a .php-version file for this directory (interactive picker)
pvm init
```
### Auto-Switching
If you run `pvm init` or manually create a `.php-version` file in a project directory containing `8.3`, PVM will automatically switch to your best local `8.3.x` patch when you `cd` into that folder. The `cd` hook is installed via `pvm env` (Bash, Zsh, or Fish — auto-detected from `$SHELL`).