Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PHP using Homebrew on MAC

Tags:

I am trying to install PHP on my MAC machine using Homebrew. I am using the following command: brew install php

However, I am getting the following errors:

Error: No available formula with the name "php" 
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
like image 678
me24hour Avatar asked Mar 01 '17 17:03

me24hour


People also ask

Can you install PHP on Mac?

PHP is bundled with macOS since macOS X (10.0. 0) prior to macOS Monterey (12.0. 0). Compiling is similar to the Unix installation guide.

Why is PHP deprecated in macOS?

PHP 7.0, and PHP 7.1 have been deprecated and removed from Brew because they are out of support, and while it's not recommended for production, there are legitimate reasons to test these unsupported versions in a development environment.


1 Answers

Update

In February 2018, the php72 formula (the current version of PHP at that time) has been moved into the core Homebrew tap and renamed as php.

The homebrew/php tap has been deprecated in January 2018 and then archived on March 31, 2018. The formulas it contained are not available any more.

Since February 2018, installing PHP using Homebrew is as easy as:

$ brew install php

The older PHP versions that are still maintained can be installed using the new @ convention for versions (PHP 7.1 is [email protected]).


The original answer (not usable any more)

The PHP ecosystem lives in the homebrew/php tap. You can find there six versions of the interpreter (from 5.3 to 7.1), extensions for them and some PHP-related tools.

In order to install PHP you have to install the homebrew/php tap first (this is needed only once):

$ brew tap homebrew/php
$ brew install php70

Or you can do both operations in a single step by running:

$ brew install homebrew/php/php70

You could discover all these by searching php first:

$ brew search php
like image 76
axiac Avatar answered Sep 21 '22 07:09

axiac