PHP Version Switcher (PVS) - plugin for Oh My Zsh. Automatically
switches PHP versions based on .php-version
files. Uses PATH manipulation for user-level version management.
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/radoslav-grencik/php-version-switcher.git php-version-switcher
Edit ~/.zshrc
to enable the plugin:
plugins=(... php-version-switcher)
Reload the shell.
cd ~/.oh-my-zsh/custom/plugins/php-version-switcher
git pull
Reload the shell.
To switch to a specific version, use pvs_use [version]
:
pvs_use # switch to version defined in .php-version file or default version when no .php-version file found
pvs_use 8.2 # switch to specific version
To create a .php-version
file with a specific version, use pvs_local <version>
:
pvs_local 8.2
This will create a .php-version
file with the specified version.
To show the current info, use pvs_info
:
pvs_info
This will show the current PHP version, the version file and other information.
To show the help, use pvs_help
:
pvs_help
This will show the available commands and configuration options.
The plugin can be configured with environment variables. The following variables can be set:
PVS_VERSION_FILE
: Version file name (default:.php-version
)PVS_BIN_DIR
: Directory for PHP symlinks (default:~/.local/bin/pvs
)PVS_PHP_INSTALL_DIR
: PHP installation directory (default:auto-detected
)PVS_AUTO_SWITCH
: Auto-switch when changing directories (default:true
)PVS_QUIET_MODE
: Quiet mode - less verbose output (default:false
)PHP_DEFAULT_VERSION
: Default PHP version when no.php-version
file found (default:newest available version
)
This project is licensed under the MIT License.