This article summarizes four methods to quickly switch multiple php versions under macos, which is very simple and practical, for more information about how to quickly switch multiple php versions on mac OS, see the following section.
Php is an open-source language widely accepted to quickly build a web page. through continuous development, many open-source php systems are available to meet the site requirements of most users. Since the birth of php in early 1995, multiple versions already exist, and each version belongs to a series. most website source code cannot be compatible with each other, so it is very practical to switch the PHP version quickly.
Method 1
1. add a tap
brew tap josegonzalez/php
2. install multiple versions of PHP
brewinstallphp53brewinstallphp54
3. create a switch script
mkdir-p ~/.bin/php-switchcd~/.bin/php-switchcurl -L #> php-switchchmod+x php-switch
You need to add the php-switch to PATH. you can add it to. bash_profile, so that the php-switch can be automatically loaded upon startup.
4. Finally, you can use the following command to switch to the php version:
php-switch
Method 2
You can directly install the switch tool through homebrew.
brew tap homebrew/dupesbrew tap josegonzalez/homebrew-phpbrewinstallphp-version# Homebrew (recommended)source$(brew --prefix php-version)/php-version.sh && php-version 5
After the above installation is complete, you can also switch through php-version.
Method 3
Install switch tool
npminstall-g brew-php-selectLoadModule php5_module /usr/local/php/libexec/apache2/libphp5.so
You can use the following command to switch
brew-php-select
Method 4
Note: all php versions are required to be installed by brew.
I. use brew to install php multi-version
# brew install php56 # brew install php71
II. install the switch tool
# brew install php-version# source $(brew --prefix php-version)/php-version.sh
3. View all installed versions
# php-version
4. Switch versions
# php-version 5.6.5
The above describes how to quickly switch between multiple PHP versions for mac OS. For more information, see PHP Chinese network (www.php1.cn )!