Skip to content

stefanwimmer128/phpenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phpenv

Easily swith php version.

Installation

Oh My Zsh

git clone https://git.stefanwimmer128.eu/stefanwimmer128/phpenv.git $ZSH_CUSTOM/plugins/phpenv

Add to plugins in .zshrc:

plugins=(phpenv)

Zsh without Oh My Zsh, Bash

git clone https://git.stefanwimmer128.eu/stefanwimmer128/phpenv.git ~/.phpenv

Source phpenv.sh

source ~/.phpenv/phpenv.sh

Usage

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.

Swith php version per folder

By using direnv you can switch php version per folder by setting PHPENV in the .envrc file:

export PHPENV="php7.4:php74"