Reputation: 719
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.
Upvotes: 41
Views: 121542
Reputation: 581
I found this solution:
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
And switching with:
brew link --overwrite [email protected]
Upvotes: 1
Reputation: 864
I ran into this error in 2021 using Mac OS Big Sur. Running the below commands helped me out
rm -rf $(brew --repo homebrew/core)
brew tap homebrew/core
brew install php
Upvotes: 25
Reputation: 11
you can run
brew doctor
to see which branch is being used for some reasons some of the formulas are not on the origin....so kindly checkout to master on brew
git -C $(brew --repo homebrew/core) checkout master
and then try to run
brew search php
to see if its listed
Upvotes: 0
Reputation: 72216
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 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
Upvotes: 65
Reputation: 408
After installing PHP with brew,
brew install [email protected]
or any version you need(could be: [email protected])
run this command to ensure you have PHP installed: brew list | grep php
then you need to manually add an alias as follows:
alias php='/usr/local/Cellar/[email protected]/7.3.13/bin/php'
Then, for the change to take effect you need to refresh your terminal. You can use: source ~/.bash_profile
command, or close and open terminal.
Upvotes: 28