pvm is a small PHP version manager for development machines using PHP builds from Homebrew.
It creates a php shim and resolves the active version from:
.php-versionin the current directory or a parent directory.- The global version in
~/.config/pvm/global. - The default fallback version,
8.2.
Clone this repository and add bin to your PATH:
export PATH="$HOME/Work/personal/pvm/bin:$HOME/.local/pvm/shims:$PATH"To make it permanent, add that line to your shell profile.
Or install directly from the Git repository:
curl -fsSL https://raw.githubusercontent.com/thiagolepidus/pvm/main/install.sh | bashThe remote installer installs Homebrew when it is missing, configures the shivammathur/php and
shivammathur/extensions taps, installs pvm, and adds Homebrew plus pvm to your shell profile.
If your fork uses a different raw URL, override the source URL:
curl -fsSL https://raw.githubusercontent.com/USER/pvm/main/install.sh \
| PVM_SOURCE_URL=https://raw.githubusercontent.com/USER/pvm/main/bin/pvm bashInstall a PHP version:
pvm install 8.2Supported versions are 5.6, 7.0 to 7.4, and 8.0 to 8.6.
Install PHP with extensions:
pvm install 7.4 --with-extensions xdebug redis imagickSet the global PHP version:
pvm use 8.2Set the PHP version for the current project:
pvm use --local 7.4Show the active version:
pvm currentRun PHP normally:
php -v
php -S 127.0.0.1:8082 -t public- Homebrew.
- The
shivammathur/phptap for PHP versions. - The
shivammathur/extensionstap for optional external extensions.
pvm install taps the required repositories automatically:
brew tap shivammathur/php
brew tap shivammathur/extensionsPHP formulas use the php@<version> naming convention, for example:
shivammathur/php/php@7.4
shivammathur/php/php@8.2External extension formulas use the <extension>@<version> naming convention, for example:
shivammathur/extensions/xdebug@8.2