Skip to content

radoslav-grencik/php-version-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

PHP Version Switcher (PVS)

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.

Install

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.

Update

cd ~/.oh-my-zsh/custom/plugins/php-version-switcher
git pull

Reload the shell.

Usage

Switching versions

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

Creating .php-version files

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.

Showing current info

To show the current info, use pvs_info:

pvs_info

This will show the current PHP version, the version file and other information.

Showing help

To show the help, use pvs_help:

pvs_help

This will show the available commands and configuration options.

Configuration

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)

License

This project is licensed under the MIT License.

About

PHP Version Switcher (PVS) - plugin for Oh My Zsh.

Topics

Resources

License

Stars

Watchers

Forks

Languages