phpv · v0.14.1 · MIT · linux · darwin

PHP has no prebuilt Linux binaries. phpv compiles them.

Every other major language ships prebuilt binaries. PHP does not. phpv resolves the full transitive dependency graph, reuses what your system already has, builds the rest from source, and compiles PHP with the correct --with-* flags. phpv install 8.4 actually works.

$ curl -fsSL https://raw.githubusercontent.com/supanadit/phpv/main/install.sh | bash
[01/06] why phpv

PHP is the only major language without prebuilt Linux binaries.

  • ⌗ p-01 Node, Python, Ruby, Go — all ship official binaries. PHP expects you to compile.
  • ⌗ p-02 Compiling PHP by hand means hunting down OpenSSL, libxml2, curl, zlib, oniguruma and ICU.
  • ⌗ p-03 Getting the --with-* flags right for your extensions is a black art.
  • ⌗ p-04 Version managers like phpenv and phpbrew punt: they assume the deps are already there.

phpv makes the whole thing deterministic — and it actually works.

[02/06] build-steps

What phpv does for you.

f-01

Transitive dependency graph

Resolves the full graph — OpenSSL, libxml2, curl, zlib, oniguruma, ICU — per extension per PHP version. Deterministic resolution for 7.x/8.0/8.1/8.2+ alike.

GRAPH
f-02

Reuse what you have

System packages that satisfy the required version constraints are used directly — no source download, no rebuild. Only what is actually missing gets compiled.

SYSTEM
f-03

Correct --with-* flags

Compiles PHP with the right configure flags for your extension list. 25 default extensions work out of the box.

BUILD
f-04

Ephemeral per-shell use

phpv use 8.3 in terminal A and phpv use 8.4 in terminal B — each shell gets its own version without touching the global default. Requires phpv init.

SHELL
f-05

Per-project .php-version

Drop a .php-version file in a repo and phpv auto-switches on cd. No more remembering which PHP a project needs.

PROJECT
f-06

Per-version isolation

Each PHP version gets its own install prefix and phar directory. No conflicts between versions, ever.

ISOLATE
f-07

Extension management

phpv extension add/remove/list with --auto-deps, --dry-run and --no-system. Recommends distro-specific dev libraries before building.

EXT
f-08

PHAR & PECL tools

phpv phar install composer|pie|wp-cli|phpunit per version, and phpv pecl install/list/uninstall. Each PHP version keeps its own tools.

TOOLS
f-09

Portable bundles

phpv share 8.4 exports a portable tar.gz; phpv install 8.4 --from bundle.tar.gz imports it. Move builds between machines.

BUNDLE
f-10

phpv doctor

System readiness check plus extension analysis. Reports missing dev-libraries with distro-specific install commands.

DIAG
f-11

PHP 5.x → 8.x support

From PHP 5.0 (experimental) through 8.x, with per-version default extension sets. Auto-bundles OpenSSL 1.1.1w for 7.4.

RANGE
f-12

Parallel, visible builds

phpv install 8.4 --jobs 4 for parallel make. Per-package download progress with completion counts — no frozen spinners.

SPEED
[03/06] usage

The same PHP version management you currently do by hand — as a few deterministic commands.

# Install PHP 8.4 — 25 default extensions, deps auto-resolved,
# built from source if needed.
phpv install 8.4

# Customize the extension list
phpv install 8.4 --ext openssl,curl,apcu
phpv install 8.4 --minimal          # bare build (--disable-all --enable-cli)
phpv install 8.4 --jobs 4            # parallel make
phpv install 8.4 --fresh            # clean rebuild, keep cached source
# Initialize your shell (add to ~/.bashrc, ~/.zshrc, or fish config)
eval "$(phpv init bash)"

# Switch versions — per-shell, ephemeral
phpv use 8.3                         # current shell only
phpv use system                      # stop pinning, fall back to default
phpv use 8.3 --global                # global default
phpv default 8.3                     # set global default
phpv versions                        # list installed
phpv which                           # path to current PHP
# Per-project version via .php-version — auto-switch on cd
echo "7.2" > .php-version

# Now every shell that enters this directory uses PHP 7.2
# (requires `phpv init` in your shell config)
# List what's available / installed
phpv extension list
phpv extension available 8.4

# Add an extension into the active version
phpv extension add pdo_pgsql
#   → recommends installing postgresql-libs (Arch) /
#     libpq-dev (Debian/Alpine) / postgresql-devel (Fedora)

phpv extension add redis --auto-deps --dry-run
phpv extension remove xdebug
# Manage PHAR tools — per-version, each PHP has its own phars
phpv phar install composer
phpv phar install pie
phpv phar install wp-cli
phpv phar install composer --version 8.4
phpv phar update composer
phpv phar list
phpv phar which composer
# Export a PHP build as a portable bundle
phpv share 8.4                       # → bundle.tar.gz

# Import it on another machine
phpv install 8.4 --from bundle.tar.gz
# System readiness check
phpv doctor

# Extension analysis for a specific version
phpv doctor 8.4

# Full verbose rebuild when something's off
phpv install 8.4 --fresh --verbose
[04/06] build-log

How it works.

phpv turns "compile PHP from source" into a single deterministic command. It resolves the dependency graph, reuses what your system already has, builds only what is missing, and compiles PHP with the correct flags.

Dependencies are keyed by (name, version) and shared across PHP versions that pin the same version — build once, reuse everywhere. phpv only downloads and extracts what it will actually compile; system packages that satisfy the required version constraints are used directly, and build tools come from the system.

[00:00] → phpv use 8.4 — resolve the dependency graph
[00:01] → Check system libs — reuse what satisfies the constraints
[00:02] → Download only the missing sources (per-package progress)
[00:03] → Build missing deps from source
[00:04] → Compile PHP with the correct --with-* flags
[00:05] → Activate the shim / shell function — this shell only
[05/06] commands

Command reference.

The full phpv command surface, grouped by workflow. Every command is a single binary — no runtime dependencies.

phpv — command reference

Install & build

phpv install <ver>

Install a PHP version with default extensions

phpv rebuild <ver>

Rebuild PHP with different extensions (keeps deps)

phpv uninstall <ver>

Remove an installed PHP version

phpv share <ver>

Export PHP as a portable bundle

Switching

phpv use <ver>

Switch for current shell (ephemeral; --global for global)

phpv default <ver>

Set global default PHP version

phpv versions

List installed PHP versions

phpv which

Show path to current PHP binary

Extensions

phpv extension list [ver]

List installed extensions

phpv extension available [ver]

List extensions available for a version

phpv extension add <name>…

Install extensions into the active version

phpv extension remove <name>…

Remove extensions from the active version

PHAR & PECL

phpv phar install <name> [ver]

Install a PHAR tool (composer/pie/wp-cli/phpunit)

phpv phar update <name> [ver]

Update a PHAR tool

phpv pecl install <name|archive> [ver]

Install a PECL extension

phpv pecl uninstall <name> [ver]

Remove a PECL extension

System & tools

phpv init <shell>

Generate shell integration (bash/zsh/fish/pwsh/ksh)

phpv doctor [ver]

System readiness check + extension analysis

phpv update

Self-update phpv

phpv completion <shell>

Generate shell completion

[06/06] install · v0.14.1

Install phpv.

The recommended path is the one-line installer: it detects your platform and shell, installs to $PHPV_ROOT/bin (default ~/.phpv), and wires up shell integration automatically. Prebuilt binaries and building from source are also supported.

curl -fsSL https://raw.githubusercontent.com/supanadit/phpv/main/install.sh | bash
git clone https://github.com/supanadit/phpv.git && cd phpv && go build -o phpv ./app/phpv.go

The installer detects your platform and shell, installs to $PHPV_ROOT/bin (default ~/.phpv), and appends the phpv init line to your shell config automatically. Pin a version with INSTALL_VERSION=0.11.0. Prefer a manual install? Grab a binary from the releases page — each ships with a matching .sha256 file.

sh
# The installer adds `eval "$(phpv init <shell>)"` to your shell config
# automatically. Restart your shell (or source the config), then:
phpv which          # path to the current PHP binary
phpv versions       # list installed PHP versions
phpv install 8.4    # 25 default extensions, deps auto-resolved
phpv use 8.4 --global
[06/06] faq

Questions, answered.

>What exactly is phpv?

phpv is a PHP version manager written in Go. It resolves the full transitive dependency graph — OpenSSL, libxml2, curl, zlib, oniguruma, ICU — checks what is already on your system, builds what is missing from source, then compiles PHP with the correct --with-* flags. phpv install 8.4 actually works.

>Why does phpv compile instead of downloading binaries?

Because PHP has no prebuilt Linux binaries. Every other major language ships them; PHP does not. phpv makes compiling deterministic: it reuses system packages that satisfy the version constraints, builds only what is missing, and compiles with the right flags.

>Does phpv use touch my system PHP?

No. Each PHP version gets its own isolated install prefix under $PHPV_ROOT (default ~/.phpv). phpv use switches the current shell only — it never touches the global default unless you pass --global.

>Which shells are supported?

phpv init generates shell integration for bash, zsh, fish, pwsh and ksh. The ephemeral per-shell use switching works across all of them.

>Where does phpv install itself?

The installer puts the binary at $PHPV_ROOT/bin/phpv (default ~/.phpv/bin) — no sudo, no /usr/local/bin. Each PHP version gets its own isolated prefix under the same root, and the installer appends the phpv init line to your shell config automatically.

>Can I pin a specific phpv version?

Yes. Set INSTALL_VERSION before running the installer, e.g. INSTALL_VERSION=0.11.0 curl -fsSL https://raw.githubusercontent.com/supanadit/phpv/main/install.sh | bash. Otherwise the latest release is detected automatically.

>What licence is phpv under?

MIT. The current release is v0.14.1; install with the one-liner, download a binary from the GitHub releases page, or build from source.

Stop fighting your PHP versions.

One binary. Full dependency resolution. Compiles from source. phpv install 8.4 actually works.

Get started →