Homebrew PHP appears not to be linked. - Valet - php

I had a problem which appeared all of the sudden saying:
Unable to determine linked PHP. which I could not solve so I uninstalled valet, php and dependencies. Then I installed fresh php7.1 but when I run valet install I get quiet slightly similar error: Homebrew PHP appears not to be linked.

First, find the PHP version installed via.
brew list
In my case it was php#7.3, then
brew link php#7.3 --force --overwrite
and finally
valet install
:)

Homebrew can't find the correct PHP version, have you linked them up properly?
brew link php71

brew link php#7.2 --force --overwrite
That will push this--
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/php#7.2/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.2/sbin:$PATH"' >> ~/.bash_profile
I ran both independently then tried valet install (worked like a charm).

brew install php#7.1
then link it
brew link php#7.1 --force --overwrite

$ brew unlink php && brew link --force php#7.1

If you are coming here following a migration from Intel to M1 and having Valet not use the php cask from the /opt/ folder, this did the trick for me:
echo "export PATH=/opt/homebrew/bin:$PATH" >> ~/.zshrc.

Related

php -v always returns php#5.6

Installed php#5.6 and php#8.1 with brew. php -v shows php#5.6 after brew link php#5.6 --force --overwrite (normal).
Then, after using brew unlink php#5.6 and brew link php --force --overwrite to switch to php#8.1, php -v still displays php#5.6.
In other words, I'm stuck with php#5.6 and cannot switch to php#8.1.
I know I edited a config file and added a line specifying php#5.6, but I can't remember which file it was.
How can I switch to php#8.1?
I'm using brew in Ubuntu via WSL 2 under Windows. Thanks.
try splitting the command into two like so
brew unlink php && brew link --overwrite --force php#8.1
The command above works for me.
Ref: https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions

Error when install PHP with brew in OS Monterey

I got php is deleted in OS Monterey, so I try to install it via Homebrew
I already install Homebrew, update tap to shivammathur/php and use this command
brew install shivammathur/php/php#7.4
but I got this response code
fatal: Could not resolve HEAD to a revision
Warning: No available formula with the name "httpd" (dependency of shivammathur/php/php#7.4).
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
When I check brew version with brew --version I got this info
Homebrew 3.3.2
Homebrew/homebrew-core (no Git repository)
Homebrew/homebrew-cask (git revision 5c43c2133d; last commit 2021-11-06)
is that no Git repository issue related with why I cant install php in my device? How to solve this issue
I need this to install composer and install Laravel, so install XAMPP I think is not clear solution right now
Thankyou
I recently had this exact problem and tried
brew tap homebrew/core
However, it didn't work. This did work for me
rm -rf $(brew --repo homebrew/core)
brew tap homebrew/core
brew install php
Hope this helps!
As the output of brew --version says homebrew-core repository is missing, that is why brew is not able to find httpd.
Homebrew/homebrew-core (no Git repository)
Please tap the core repository and try again.
brew tap homebrew/core
Try write this in terminal:
git -C $(brew --repository homebrew/core) checkout master

Update PHP to 7.4 macOS Catalina with brew

I try to update my PHP version to 7.4 on macOS Catalina with brew.
I did brew install php#7.4
If I check my version php -v, I still see the old version PHP 7.3.11?
What do I have to do?
Update:
After brew doctor I get:
Warning: Homebrew's sbin was not found in your PATH but you have
installed formulae that put executables in /usr/local/sbin. Consider
setting the PATH for example like so: echo 'export
PATH="/usr/local/sbin:$PATH"' >> ~/.profile
You can find my similar answer for php#7.2.
brew install php#7.4
brew link --force --overwrite php#7.4
brew services start php#7.4
export PATH="/usr/local/opt/php#7.4/bin:$PATH"
export PATH="/usr/local/opt/php#7.4/sbin:$PATH"
try:
brew update
brew upgrade php
php -v
brew services start php
or
brew services restart php
if you use apache server:
sudo apachectl restart
if you use ngnix
sudo nginx -s reload
Edit:
brew unlink php#7.3
brew link php#7.4
If anyone want to downgrade php from latest 8.1.2 to 7.4 on systems demand, try the below commands with homebrew:
Installing PHP 7.4 :
brew install php#7.4
brew services restart php
brew unlink php#8.1
brew link php#7.4
echo 'export PATH="/usr/local/opt/php#7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php#7.4/sbin:$PATH"' >> ~/.zshrc
Or
export PATH="/usr/local/opt/php#7.4/bin:$PATH"
export PATH="/usr/local/opt/php#7.4/sbin:$PATH"
Using terminal of MacOS. Don't use terminal in vscode.
I recently faced this issue, all the suggestion here didn't work until I ran:
xcode-select --install
Then ran the command I was trying before and the error stopped, for my case it was php
dyld: Library not loaded: /usr/local/opt/openldap/lib/libldap-2.4.2.dylib
Referenced from: /usr/local/opt/php#7.4/bin/php
Reason: image not found
zsh: abort php -v
I move to directory by: cd /usr/local
Find the file location by: find /usr/local/ -name libphp7.so. (Then get the file location at: /usr/local//Cellar/php#7.4/7.4.23/lib/httpd/modules/libphp7.so. I copy this.)
I open the file by: sudo vim /etc/apache2/httpd.conf
Look for the line by: /libphp7.so
Uncomment the line and update the line by: LoadModule php7_module /usr/local//Cellar/php#7.4/7.4.23/lib/httpd/modules/libphp7.so
Restart apache by: sudo apachectl restart
Verify PHP by accessing http://localhost/phpinfo.php

Homebrew upgrade drops PHP: dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib

Today I upgraded Homebrew and this causes PHP versions (7.2 - 7.3) to be dropped. the following error is shown whenever I try to reinstall them:
dyld: Library not loaded: /usr/local/opt/libpsl/lib/libpsl.5.dylib
Referenced from: /usr/local/opt/curl-openssl/bin/curl
Reason: image not found
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "php"
Download failed: https://www.php.net/distributions/php-7.3.9.tar.xz
Any suggestions?
Okay, I've solved this by installing this library brew install libpsl
then reinstall php brew reinstall php#7.2 --build-from-source
also the same for php#7.3
Be aware that reinstalling php will reset all php configurations
It's a bug after php was migrated to OpenSSH 1.1. There's no need to install libpsl.
The problem has been fixed by pr-44048. You should uninstall libpsl and reinstall php.
brew uninstall libpsl
brew reinstall php
Removing the Cellar folder and installing the PHP again worked for me.
rm -rf /Users/rafaelgomes/.composer/*
rm -rf /usr/local/Cellar/*
brew doctor ; brew update ; brew upgrade
brew install php
I've solved this by doing the following
brew uninstall libpsl
brew remove php
brew install libpsl
brew install php#8.0

OSX Sierra - How to Install PHP7 and leave 5.6 as default in Terminal

short question - how to install php7.1 on OS X Sierra and keep 5.6 as default.
I only want to run php 7.1 in terminal using php7 - and when using php the original 5.6 should be used ...
thanx in advance
tom
There are a number of ways to achieve this. I would install PHPBrew, since that allows you install as many PHP versions as you want without touching the system's PHP version.
I would also install Homebrew as it's likely there will be dependencies you need to resolve with specific extensions.
Another option would be to install PHP7 via Homebrew and alias it to php7. Or you could compile it from source. However, if you plan on having one or more PHP versions readily available alongside the system version then PHPBrew is probably the most flexible option.
Install PHP 5.6:
brew install php56
Install PHP 7.0:
php70
Switch to php5.6 in terminal:
brew unlink php70
brew link php56
Switch to php7.0 in terminal:
brew unlink php56
brew link php70
Source: Switching PHP version on mac with homebrew
maybe someone other is searching for a very clean solution too - here is what finally worked for me perfectly. this is based on the hints and tips from matthew daly and surfer 190 - thanx again!
takes just 5 minutes - here we go ...
first install xcode command line tools (just 160mb instead 4.5gb):
xcode-select --install
then install homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
short test if anything up to here is fine:
brew doctor
install php 7.1:
brew install php71
i found that some have problems with the above direct php install - this resolves these problems - and then try again the php install:
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
make a symlink to the original php-binary that came with osx:
ln -s /usr/bin/php /usr/local/bin/php5
here is the result - now php 7.1 is the default php version - and using php5 will use the old php-binary that came with your osx preinstalled:
php -v
php5 -v

Categories