Linux command
phpenv 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List installed PHP versions
phpenv versions
Show current version
phpenv version
Set global PHP version
phpenv global [8.2.0]
Set local PHP version
phpenv local [8.1.0]
Set shell-specific version
phpenv shell [8.0.0]
Install PHP version
phpenv install [8.2.0]
List available versions
phpenv install --list
Rehash shims
phpenv rehash
说明
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.
参数
- 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.
FAQ
What is the phpenv command used for?
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.
How do I run a basic phpenv example?
Run `phpenv versions` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does install _VERSION_ do in phpenv?
Install PHP version.