13

I need a specific version of PHP for magento (7.1.3)

With home brew or curl, I can only specify one decimal (7.1, 7.2 etc).

Running

brew install php@7.1

ultimately gets me

php -v
PHP 7.1.29 (cli) (built: May 21 2019 20:05:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.29, Copyright (c) 1999-2018, by Zend 
Technologies

trying to install a specific version (like you can with node using nvm):

brew install php@7.1.3

gets me

Error: No available formula with the name "php@7.1.3"

I tried using a curl command, same issue:

https://php-osx.liip.ch/install.sh | bash -s 7.1.3 

gets me

Did or could not download package: 7.1.3-frontenddev

TL;DR: How do i install exact version of PHP (7.1.3) on mac?

Brandon
  • 335
  • 2
  • 4
  • 15
  • 2
    Why would you need this version in particular? You're going to miss the latest bug & security fixes according to [changelog](https://www.php.net/ChangeLog-7.php#7.1.28) – gogaz May 26 '19 at 15:52
  • Plus, there should be plenty of sites on the internet where you can download that should you fail with the command line. – frogman578 May 26 '19 at 16:01

4 Answers4

23

For the deprecated php version in the brew. Please run this.

brew tap exolnet/homebrew-deprecated

Then choose your version.

brew install php@7.1

Switch back to the first PHP version.

brew link --force --overwrite php@7.1

Here is the reference,

macOS 10.15 Catalina Apache Setup: Multiple PHP Versions

  • 3
    Thanks a lot, saved me. But `exolnet/homebrew-deprecated` does not exists anymore. Replaced with `shivammathur/php` (I was able to install `shivammathur/php/php@5.6` without any issue). – Kevin Labécot Jan 06 '22 at 12:12
16

brew tap exolnet/homebrew-deprecated Is deprecated.

I recommend shivammathur/php instead. Here's an example of how to use it:

brew tap shivammathur/php

brew install shivammathur/php/php@7.3

brew link --overwrite --force shivammathur/php/php@7.3

Then restart the terminal and test your PHP version:

php -v

Gustavo Maximo
  • 4,426
  • 3
  • 17
  • 26
3

I didn`t find this tagged version on PHP git page, so probably is repacked version for some linux distribution. If you think that you need ~7.1.3 version because that wrotes on system requirements for magento, you can also use 7.2.0 as they wrote in https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html

so you can use:

brew install php@7.2

Installing old version you miss latest bug fix and security fixes so i recommend to you at least PHP 7.2.

r00t-err0r
  • 174
  • 1
  • 11
  • 1
    I did try this, but it installed 7.2.19, which didn't work with magento. How do i tell it to specifically install 7.2.0, as this is the version the docs state is compatible? – Brandon May 26 '19 at 16:10
  • I don`t see problems with php 7.2.19 because Magento 2.3.1 is certified and tested on PHP 7.2.11 so they support and versions above. Can you please support us with some errors or error logs, maybe you miss some extensions that magento requires. – r00t-err0r May 26 '19 at 16:16
0

You can try phpbrew – I needed to install a specific sub-version (brew will only allow me to install php@8.0 which will mean 8.0.26 while I specifically need 8.0.25).

Kirk Hammett
  • 656
  • 8
  • 24