alternative stack for PHP version managment in use:
direnv
zsh
+oh-my-zsh
plugindirenv
php-version
.direnvrc
use_php-version() {
local php_version=$1
phpversion_sh=$(brew --prefix php-version)/php-version.sh
if [[ -e $phpversion_sh ]]; then
source $phpversion_sh
php-version $php_version
fi
}
tested on macOS Big Sur (11.6.5)
This Repo includes an simple zsh plugin for the shell command php-version
to automatically switch between php versions if an rc-file is present.
This was heavily inspired by the rvm switch for .rvmrc files.
zsh
(duh) andoh-my-zsh
(for plugin compatibility)php-version
(used for the zsh plugin to automatically switch between php versions)
- Add the plugin into your zsh custom folder
- See the documentation from GitHub: robbyrussell/oh-my-zsh
- Add the plugin to your
.zshrc
and define an default PHP version to switch back to if there is no.phpvrc
file:
plugins=(
...
php-version_rcfile-switcher
...
)
PHPVRC_DEFAULT=7.2
- create an rc file with the name:
.phpvrc
and include the version, e.g.:7.2
This plugin was developed and tested on macOS Mojave (11.14) to work with zsh
, brew
and php-version
. For everything else you get an "maybe".
Licensed under the GNU General Public License v3.0