How to quickly switch between multiple PHP versions using macos

Source: Internet
Author: User
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 )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.