Valet: [DomainException] Unable to determine linked PHP.

Created on 21 Nov 2017  Â·  20Comments  Â·  Source: laravel/valet

already add echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc source ~/.bashrc still got this error

Most helpful comment

i use it

ln -s /usr/local/Cellar/php71/7.1.16_1/bin /usr/local/bin/php


➜  ~ valet install
Stopping nginx...
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration...
Restarting [email protected]...
Restarting dnsmasq...
Restarting nginx...

All 20 comments

According to the Valet code where the Unable to determine linked PHP message is generated, it could appear for two reasons:

  1. At https://github.com/laravel/valet/blob/master/cli/Valet/Brew.php#L179 it's checking whether a symlink exists for any php binary.
    If it's this line that's triggering it, then the fix is to run brew link php71 (or whatever PHP version you've installed with homebrew).

  2. At https://github.com/laravel/valet/blob/master/cli/Valet/Brew.php#L187 it's been checking whether the symlink is pointing to a version of PHP that Valet supports (currently 5.6, 7.0, 7.1, 7.2).
    In this case, you may need to "unlink" yourself from unsupported PHP versions, and then re-link to a supported version.

brew unlink php55
brew link php71

have installed php71, after brew link php71, got this error-- /usr/local/sbin is not writable. I googled and people recommend sudo chown -R 'whoami':admin /usr/local/sbin , but got this No such file or directory

I checked my /usr/local/, get my bin file but no sbin file

Finally get it done, under local/ , by mkdir sbin and brew link php71. Valet installed successfully!

The problem is because linkedPhp method can't match a linked PHP version. In my system the path is ../Cellar/php/7.2.2_13/bin/php.
In order to fix that, I've added a new entry to supportedPhpVersions function of ~/.composer/vendor/laravel/valet/cli/Valet/Brew.php file:

function supportedPhpVersions()
{
    return collect(['7.2', 'php72', 'php71', 'php70', 'php56']);
}

@adamwathan can we add 7.2 to the array to catch cases like this one?

If you're using dev-master or v2.0.8 or newer, then php is already in the list, so 7.2 is superfluous:

https://github.com/laravel/valet/blob/master/cli/Valet/Brew.php#L55

Ahh yeah, forgot to update, my bad. V 2.0.8 resolves the issue.

got it fixed using using 7.1:

$ brew install php
$ brew install php7.1
# for @179
$ ln -s /usr/local/Cellar/[email protected]/7.1.16 /usr/local/Cellar/php/7.1.16
# for @187
$ ln -s /usr/local/Cellar/php/7.1.16/bin/php /usr/local/bin/php
$ valet install

@kevmt this worked for me thanks! Be careful with the new [email protected] as it includes some extensions in the binary so you may have to remove some old versions of ext-mcrypt.ini etc

@robertkent gotcha

i use it

ln -s /usr/local/Cellar/php71/7.1.16_1/bin /usr/local/bin/php


➜  ~ valet install
Stopping nginx...
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration...
Restarting [email protected]...
Restarting dnsmasq...
Restarting nginx...

Issues posted above could be linked to #562

There is a fix there that worked for me:

brew link --force --ovewrrite [email protected]

For newly installed OS, this is my GIST: https://gist.github.com/kevmt/1260e58fc94c8194c24d8468fb079da6

I think it's caused by this commit to valet: https://github.com/laravel/valet/commit/84ade711b61fd79ead98e08b5186704f68b4f993

Looks like the change to collections causes the index to be compared instead of the the actual version.

Edit: This happens if you are running a version of Laravel < 5.3. To fix, run: composer global update

Reference from
https://laracasts.com/discuss/channels/laravel/laravel-valet-domainexception-unable-to-determine-linked-php

The comment above, https://github.com/laravel/valet/issues/470#issuecomment-383824154, solves this issue for me.

composer global update

My way to fix this was ti rewrite current php version: brew link [email protected] --force --overwrite
That worked for me in similar case. If you have questions in the whole process - ping me as well. Probably, I can help ;)

  1. export PATH="$PATH:$HOME/.composer/vendor/bin"'
  2. ln -s /usr/local/Cellar/php@XXXX /usr/local/bin/php
  3. valet install
    Enjoy!

After creating this PATH via your terminal:-
ln -s /usr/local/Cellar/php71/7.1.16_1/bin /usr/local/bin/php

Do this:-
➜ composer global require laravel/valet
➜ valet install

After creating this PATH via your terminal:-
ln -s /usr/local/Cellar/php71/7.1.16_1/bin /usr/local/bin/php

Do this:-
➜ composer global require laravel/valet
➜ valet install

This is the solution even if it destroys the easy way to switch php versions.
Watch out that you symlink the right path!

In my case (linking to 7.2) the symlink looked like
ln -s /usr/local/Cellar/[email protected]/7.2.13/bin/php /usr/local/bin/php

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ellisio picture ellisio  Â·  4Comments

idmahbub picture idmahbub  Â·  3Comments

VinceG picture VinceG  Â·  3Comments

Alshie picture Alshie  Â·  4Comments

EHLOVader picture EHLOVader  Â·  4Comments