I try to install php@7.3 using brew. But, it return error because it is versioned formula. What is it?
command: brew install php@7.3
result: Error: php@7.3 has been disabled because it is a versioned formula!
I try to install php@7.3 using brew. But, it return error because it is versioned formula. What is it?
command: brew install php@7.3
result: Error: php@7.3 has been disabled because it is a versioned formula!
You can only install supported versions of PHP with brew. However, there is the tap shivammathur/php
which can be used to install unsupported version of PHP.
brew tap shivammathur/php
brew install shivammathur/php/php@7.3
brew link php@7.3
The first step only needs to be done once. After adding the tap, you can install PHP version 5.6 - 8.2.
I applied the same instructions given by @derhansen and worked very well for php@7.4:
brew tap shivammathur/php
brew install shivammathur/php/php@7.4
brew link php@7.4
You can also edit the formula and re-enable it. These steps worked for me in May 2023:
brew edit php@7.4
disable! date: "2022-11-28", because: :versioned_formula
. Change 2022 to 2024 (or later).HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source php@7.4
Notes:
For anyone having this issue 2023 (and beyond)
The accepted answer is an unnessercery step.
@Mike's answer is the better one, but is missing one important step.
HOMEBREW_NO_INSTALL_FROM_API=1 brew install php@7.3
HOMEBREW_NO_INSTALL_FROM_API=1 brew install php@7.4
HOMEBREW_NO_INSTALL_FROM_API=1 brew install php@8.0
HOMEBREW_NO_INSTALL_FROM_API=1 brew install php@8.1
Brew tells you, when you edit the Formula:
Warning: Unless `HOMEBREW_NO_INSTALL_FROM_API` is set when running
`brew install`, it will ignore your locally edited formula.
Editing /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/php@7.4.rb
Warning: Using code because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR,
or HOMEBREW_EDITOR to your preferred text editor.
This way, you still use the official formula. This of course, works for any formula.
So, just remove the following two lines from the formula:
brew edit {{ formula }} // ex: brew edit php@7.4
keg_only :versioned_formula
disable! date: "2022-11-28", because: :versioned_formula
When you are using homebrew to install PHP you need to know the versions that are been supported by homebrew. If you need to install an unsupported version you can do it by running these commands
brew tap shivammathur/php
brew install shivammathur/php/php@7.4
brew link php@7.4
And then if ypu need to check the current version and then shift between php version you can run
php -v
brew unlink php
brew link php@7.4
BTW, brew install php@7.4
gives out same warning, but does install php7, so this could be an option
I was facing the same problem with Homebrew. The following steps resolved it, combining ideas from phpbrew#1249:
brew edit php@7.4
disable! date: "2022-11-28", because: :versioned_formula
pkg-config
find the compile headers of openssl v1.1.1 before the ones of v3 (which do not define RSA_SSLV23_PADDING
):
ENV["PKG_CONFIG_PATH"] = "#{Formula["openssl@1.1"].opt_prefix}/lib/pkgconfig:#{ENV["PKG_CONFIG_PATH"]}"
system "echo", ENV["PKG_CONFIG_PATH"]
ENV["OPENSSL_CFLAGS"] = "-I#{Formula["openssl@1.1"].opt_include}"
ENV["OPENSSL_LIBS"] = "-L#{Formula["openssl@1.1"].opt_prefix}/lib -lcrypto -lssl"
--with-openssl
with the following:
--with-openssl=shared,#{Formula["openssl@1.1"].opt_prefix}
HOMEBREW_NO_INSTALL_FROM_API=1 brew reinstall -s php@7.4