phpenv: Simple PHP Version Management

phpenv: Simple PHP Version Management

phpenv is a tool that allows you to install and switch between PHP versions easily. It’s ideal for simpler, PHP-only projects.

How to Install phpenv:

  1. Clone the phpenv repository:
git clone https://github.com/phpenv/phpenv.git ~/.phpenv
  1. Add phpenv to your path (e.g., in /.bash_profile or ~/.zsh_rc):
export PATH="$HOME/.phpenv/bin:$PATH"
eval "$(phpenv init -)"
  1. Install php-build plugin:
git clone https://github.com/php-build/php-build.git ~/.phpenv/plugins/php-build
  1. Install a specific PHP version:
phpenv install 7.4.1
  1. Switch PHP versions globally, per directory, or for the current shell:
phpenv global 7.4.1
phpenv local 7.4.1
phpenv shell 7.4.1