Home >Backend Development >PHP Tutorial >Switching between multiple php versions under mac (operable version)

Switching between multiple php versions under mac (operable version)

藏色散人
藏色散人forward
2019-08-30 14:13:233802browse

Switching between multiple php versions under mac (operable version)

Switching multiple php versions under mac (operable version)

Referenced multiple articles and carried out Test practice, summarized the following correct operation methods

Practice

Applicable version:

OS X Version:    10.12.3 (16D32)
--------
Homebrew 1.3.2
Homebrew/homebrew-core (git revision aeab0; last commit 2017-09-14)
--------
PHP Version in use:    php71 56

And, the premise is that you have followed php56

1.brew update

You need to update the brew software warehouse directory first

2.brew upgrade

According to In the software warehouse directory updated by the previous update, use upgrade to update all software and related dependencies. In order to ensure the correct installation of the software

Remarks:

Use doctor to print the details of the error and the installation goes smoothly. If so, there is no need to use

brew doctor

3.brew install php71

You need to install this php warehouse first

brew tap josegonzalez/homebrew-php

and then install php71

brew install php71

It should be noted that here you need to disassociate homebrew from php56 first, and then install php71

brew unlink php56

4. Install php-version

Install php-version

brew install php-version

Set the initialization of php-version

source $(brew --prefix php-version)/php-version.sh

So that you can use multiple versions

php-version   
* 5.6.30
  7.1.8
➜  ~ php -version
PHP 5.6.30 (cli) (built: Sep 15 2017 14:11:24) (DEBUG)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
➜  ~ php -version                 
PHP 7.1.8 (cli) (built: Sep 15 2017 14:26:34) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
➜  ~ php-version 
  5.6.30
* 7.1.8

Encountered problems

Error report:

dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
Referenced from: /usr/local/bin/php
Reason: Incompatible library version: php requires version 45.0.0 or later, but libpng16.16.dylib provides version 38.0.0
Abort trap: 6
dyld: Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /usr/local/Cellar/php70/7.0.22_14/bin/php
  Reason: Incompatible library version: php requires version 48.0.0 or later, but libpng16.16.dylib provides version 45.0.0

In fact, the error reports are similar. They all say that there is a problem with the libpng version. There are two solutions:

1. Update libpng. If the problem cannot be solved, jump to option 2

brew upgrade libpng

2. Don’t use php70, use php71

No matter how you test 7.0, it won’t work, just switch to 7.1

The above is the detailed content of Switching between multiple php versions under mac (operable version). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete