LinuxCommandLibrary

phpenv

manages multiple PHP versions per-project

TLDR

List installed PHP versions

$ phpenv versions
copy
Show current version
$ phpenv version
copy
Set global PHP version
$ phpenv global [8.2.0]
copy
Set local PHP version
$ phpenv local [8.1.0]
copy
Set shell-specific version
$ phpenv shell [8.0.0]
copy
Install PHP version
$ phpenv install [8.2.0]
copy
List available versions
$ phpenv install --list
copy
Rehash shims
$ phpenv rehash
copy

SYNOPSIS

phpenv [install] [global] [local] [shell] [versions] [options] [version]

DESCRIPTION

phpenv manages multiple PHP versions per-project. It uses shims to intercept PHP commands and route them to the correct version.
Version selection follows a hierarchy: PHPENV_VERSION environment variable, .php-version file in current/parent directories, global version setting.
The local command creates a .php-version file in the current directory. When entering that directory, phpenv automatically uses the specified version.
Installation requires php-build plugin, which compiles PHP from source. Build dependencies must be installed first.
After installing PHP extensions or PEAR packages, run rehash to create shims for new executables.
The architecture mirrors rbenv for Ruby, providing familiar version management for polyglot developers.

PARAMETERS

install VERSION

Install PHP version.
install --list
List available versions.
versions
List installed versions.
version
Show current version.
global [VERSION]
Set/show global version.
local [VERSION]
Set/show local version.
shell [VERSION]
Set shell-specific version.
rehash
Rebuild shim executables.
which CMD
Show path for command.
root
Show phpenv root.

CAVEATS

Compiling PHP requires build dependencies. Build times can be significant. Shell initialization required. Some extensions may need manual configuration.

HISTORY

phpenv was modeled after rbenv to provide similar version management for PHP. It uses the same shim-based approach and plugin architecture, making PHP version management consistent with other language environments.

SEE ALSO

php(1), composer(1), rbenv(1), php-build(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community