Valet-plus: PHP 7.2 not working

Created on 18 Jun 2018  路  14Comments  路  Source: weprovide/valet-plus

I managed to get all PHP-versions to work, except PHP 7.2. Any tips?

valet use 7.0

[[email protected]] Unlinking
Unlinking /usr/local/Cellar/[email protected]/7.1.18... 345 symlinks removed

[libjpeg] Relinking
[[email protected]] Linking
Linking /usr/local/Cellar/[email protected]/7.0.30... 132 symlinks created

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[PECL] Updating PECL channel: pecl.php.net
[PECL] Installing extensions
        apcu_bc is already installed, skipping...
        apcu_bc is already enabled, skipping...
        geoip is already installed, skipping...
        geoip is already enabled, skipping...
[PECL-CUSTOM] Installing extensions
[[email protected]] Restarting
Valet is now using [email protected]

valet use 7.1

[[email protected]] Unlinking
Unlinking /usr/local/Cellar/[email protected]/7.0.30... 132 symlinks removed

[libjpeg] Relinking
[[email protected]] Linking
Linking /usr/local/Cellar/[email protected]/7.1.18... 132 symlinks created

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[PECL] Updating PECL channel: pecl.php.net
[PECL] Installing extensions
        apcu_bc is already installed, skipping...
        apcu_bc is already enabled, skipping...
        geoip is already installed, skipping...
        geoip is already enabled, skipping...
[PECL-CUSTOM] Installing extensions
[[email protected]] Restarting
Valet is now using [email protected]

valet use 7.2

[[email protected]] Unlinking
Unlinking /usr/local/Cellar/[email protected]/7.1.18... 132 symlinks removed

[libjpeg] Relinking
[[email protected]] Installing
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
PHP Warning:  readlink(): No such file or directory in /Users/luuk/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 314

Warning: readlink(): No such file or directory in /Users/luuk/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 314

In Brew.php line 274:

  Unable to determine linked PHP.  


use [<phpVersion>]

All previous steps: https://github.com/weprovide/valet-plus/issues/191

Bug HELP WANTED

All 14 comments

Check for /usr/local/etc/php/7.2/pear.conf. And make sure your ~/.pearrc does not overwrite the php_ini key.

cat /usr/local/etc/php/7.2/pear.conf

#PEAR_Config 0.9
a:34:{s:9:"cache_dir";s:15:"/tmp/pear/cache";s:15:"default_channel";s:12:"pear.php.net";s:16:"preferred_mirror";s:12:"pear.php.net";s:13:"remote_config";s:0:"";s:13:"auto_discover";i:0;s:13:"master_server";s:12:"pear.php.net";s:10:"http_proxy";s:0:"";s:7:"php_dir";s:21:"/usr/local/share/pear";s:7:"ext_dir";s:32:"/usr/local/lib/php/pecl/20170718";s:7:"doc_dir";s:25:"/usr/local/share/pear/doc";s:7:"bin_dir";s:22:"/usr/local/opt/php/bin";s:8:"data_dir";s:26:"/usr/local/share/pear/data";s:7:"cfg_dir";s:25:"/usr/local/share/pear/cfg";s:7:"www_dir";s:28:"/usr/local/share/pear/htdocs";s:7:"man_dir";s:20:"/usr/local/share/man";s:8:"test_dir";s:26:"/usr/local/share/pear/test";s:8:"temp_dir";s:14:"/tmp/pear/temp";s:12:"download_dir";s:18:"/tmp/pear/download";s:7:"php_bin";s:26:"/usr/local/opt/php/bin/php";s:10:"php_prefix";s:0:"";s:10:"php_suffix";s:0:"";s:7:"php_ini";s:30:"/usr/local/etc/php/7.2/php.ini";s:12:"metadata_dir";s:0:"";s:8:"username";s:0:"";s:8:"password";s:0:"";s:7:"verbose";i:1;s:15:"preferred_state";s:6:"stable";s:5:"umask";i:18;s:9:"cache_ttl";i:3600;s:8:"sig_type";s:3:"gpg";s:7:"sig_bin";s:18:"/usr/local/bin/gpg";s:9:"sig_keyid";s:0:"";s:10:"sig_keydir";s:31:"/usr/local/etc/php/7.2/pearkeys";s:10:"__channels";a:3:{s:12:"pecl.php.net";a:0:{}s:5:"__uri";a:0:{}s:11:"doc.php.net";a:0:{}}}%

cat ~/.pearrc

#PEAR_Config 0.9
a:1:{s:10:"__channels";a:3:{s:5:"__uri";a:0:{}s:11:"doc.php.net";a:0:{}s:12:"pecl.php.net";a:0:{}}}%

Looks like valet-plus is unable to determine the linked PHP when unlinking to 7.2. Could you show us the symlink of /usr/local/bin/php after switching (and failing).

php -v

PHP 7.0.30 (cli) (built: Apr 26 2018 11:49:41) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.30, Copyright (c) 1999-2017, by Zend Technologies

ls -la /usr/local/bin/php

lrwxr-xr-x  1 luuk  admin  32 Jun 18 14:40 /usr/local/bin/php -> ../Cellar/[email protected]/7.0.30/bin/php

valet use 7.2

[email protected]] Unlinking
Unlinking /usr/local/Cellar/[email protected]/7.0.30... 25 symlinks removed

[libjpeg] Relinking
[[email protected]] Installing
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
PHP Warning:  readlink(): No such file or directory in /Users/luuk/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 314

Warning: readlink(): No such file or directory in /Users/luuk/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 314

In Brew.php line 274:

  Unable to determine linked PHP.  


use [<phpVersion>]

php -v

PHP 7.1.16 (cli) (built: Apr  1 2018 13:14:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

ls -la /usr/local/bin/php

ls: /usr/local/bin/php: No such file or directory

ls /usr/local/Cellar/php*

/usr/local/Cellar/php:
7.2.6

/usr/local/Cellar/[email protected]:
5.6.36

/usr/local/Cellar/[email protected]:
7.0.30

/usr/local/Cellar/[email protected]:
7.1.18

brew unlink [email protected] && brew link [email protected]

Unlinking /usr/local/Cellar/php/7.2.6... 0 symlinks removed
Linking /usr/local/Cellar/php/7.2.6... 24 symlinks created

php -v

PHP 7.2.6 (cli) (built: May 25 2018 06:18:43) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.6, Copyright (c) 1999-2018, by Zend Technologies

valet use 7.2

Already on this version

valet use 7.0

[[email protected]] Unlinking
Unlinking /usr/local/Cellar/php/7.2.6... 24 symlinks removed

[libjpeg] Relinking
[[email protected]] Linking
Linking /usr/local/Cellar/[email protected]/7.0.30... 25 symlinks created

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[PECL] Updating PECL channel: pecl.php.net
[PECL] Installing extensions
        apcu_bc is already installed, skipping...
        apcu_bc is already enabled, skipping...
        geoip is already installed, skipping...
        geoip is already enabled, skipping...
[PECL-CUSTOM] Installing extensions
[[email protected]] Restarting
Valet is now using [email protected]

php -v

PHP 7.0.30 (cli) (built: Apr 26 2018 11:49:41) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.30, Copyright (c) 1999-2017, by Zend Technologies

valet use 7.2

[[email protected]] Unlinking
Unlinking /usr/local/Cellar/[email protected]/7.0.30... 25 symlinks removed

[libjpeg] Relinking
[[email protected]] Installing
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
[[email protected]] Stopping
PHP Warning:  readlink(): No such file or directory in /Users/luuk/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 314

Warning: readlink(): No such file or directory in /Users/luuk/.composer/vendor/weprovide/valet-plus/cli/Valet/Filesystem.php on line 314

In Brew.php line 274:

  Unable to determine linked PHP.  


use [<phpVersion>]

Not sure how in depth you're to debugging valet-plus. However could you check the following:

Within PhpFpm.php there is the following code somewhere near line 174:

        // If [email protected] was not installed, it installed and automagically linked itself.
        // If we try to link it again it will throw an already linked warning.
        // PHP 5.6, 7.0 and 7.1 do not show this behaviour probably because they're not the default formulae.
        if(!(!$installed && $version === $this->sanitizeVersion(Brew::PHP_V72_FORMULAE))){
            info("[php@$version] Linking");
            output($this->cli->runAsUser('brew link php@' . $version.' --force --overwrite'));
        }

Please comment out the if statement so the code looks like:

        // If [email protected] was not installed, it installed and automagically linked itself.
        // If we try to link it again it will throw an already linked warning.
        // PHP 5.6, 7.0 and 7.1 do not show this behaviour probably because they're not the default formulae.
        //if(!(!$installed && $version === $this->sanitizeVersion(Brew::PHP_V72_FORMULAE))){
            info("[php@$version] Linking");
            output($this->cli->runAsUser('brew link php@' . $version.' --force --overwrite'));
        //}

And then try linking to PHP 7.2.

With the lines commented, it works as expected.

$installed = $this->brew->installed('php@' . $version);
function installed($formula)
    {
        return in_array($formula, explode(PHP_EOL, $this->cli->runAsUser('brew list | grep ' . $formula)));
    }

brew list | grep [email protected] indeed returns nothing, because it is the default:

brew list | grep php

php
[email protected]
[email protected]
[email protected]

ls /usr/local/Cellar/php*

/usr/local/Cellar/php:
7.2.6

/usr/local/Cellar/[email protected]:
5.6.36

/usr/local/Cellar/[email protected]:
7.0.30

/usr/local/Cellar/[email protected]:
7.1.18

@luukschakenraad Very well I will look into improving that bit of code. Thanks for testing. Will get back to you asap.

Do you want me to look into this issue too @Neodork ?

I got this working by manually changing the default version from 7.1 to 7.2.

Strange that there鈥檚 configuration for 7.2 yet the default is 7.1. I think the default should be whatever brew install php returns, then add configuration for legacy versions if desired.

Is there any update? I'm having the same issues for [email protected]

The homebrew developer should really stop messing around with php versions.

Pre-installing PHP via Homebrew (versions 5.6-7.3) prior to installing Valet Plus worked for me.

Although, for me, choosing not to install Valet Plus and opting for Valet + nss + mkcert turned out to be the best solution.

The problem seems to be that Homebrew labels "[email protected]" as "php" (all the other versions are named in the "php@version" format)... So every time that I switch from any version to 7.2, valet wants to install "[email protected]" even thou I already have it installed.

@Neodork @samgranger I've created a pull request to solve this issue. If you have any questions or remarks, please let me know.

We have fixed this issue in the latest release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eclectic-coding picture eclectic-coding  路  31Comments

SanderAtom picture SanderAtom  路  23Comments

dwillitzer picture dwillitzer  路  18Comments

MaxSouza picture MaxSouza  路  46Comments

ezequielalba picture ezequielalba  路  15Comments