Easily swith php
version.
git clone https://git.stefanwimmer128.eu/stefanwimmer128/phpenv.git $ZSH_CUSTOM/plugins/phpenv
Add to plugins in .zshrc
:
plugins=(phpenv)
git clone https://git.stefanwimmer128.eu/stefanwimmer128/phpenv.git ~/.phpenv
Source phpenv.sh
source ~/.phpenv/phpenv.sh
By setting the PHPENV
environment variable you can define which php binary you want to use for the php
command.
php --version # 8
PHPENV=php7.4 php --version # 7.4
You can define multiple options in PHPENV
(divided by :
):
PHPENV=php74:php7.4 php --version # 7.4
It tries calling php74
first, and if not continues with php7.4
.
By using direnv
you can switch php version per folder by setting PHPENV
in the .envrc
file:
export PHPENV="php7.4:php74"