valet: Error after upgrading PHP: "Uncaught Error: Call to undefined function Valet\collect()"

I just upgraded my PHP from 7.3 to 7.4, and valet install gives me this error:

PHP Fatal error:  Uncaught Error: Call to undefined function Valet\collect() in /Users/sully/.composer/vendor/laravel/valet/cli/Valet/Configuration.php:202
Stack trace:
#0 /Users/sully/.composer/vendor/laravel/valet/cli/includes/helpers.php(149): Valet\Configuration->Valet\{closure}(Array)
#1 /Users/sully/.composer/vendor/laravel/valet/cli/Valet/Configuration.php(205): Valet\tap(Array, Object(Closure))
#2 /Users/sully/.composer/vendor/laravel/valet/cli/includes/facades.php(28): Valet\Configuration->prune()
#3 /Users/sully/.composer/vendor/laravel/valet/cli/valet.php(43): Facade::__callStatic('prune', Array)
#4 {main}
  thrown in /Users/sully/.composer/vendor/laravel/valet/cli/Valet/Configuration.php on line 202

Fatal error: Uncaught Error: Call to undefined function Valet\collect() in /Users/sully/.composer/vendor/laravel/valet/cli/Valet/Configuration.php:202
Stack trace:
#0 /Users/sully/.composer/vendor/laravel/valet/cli/includes/helpers.php(149): Valet\Configuration->Valet\{closure}(Array)
#1 /Users/sully/.composer/vendor/laravel/valet/cli/Valet/Configuration.php(205): Valet\tap(Array, Object(Closure))
#2 /Users/sully/.composer/vendor/laravel/valet/cli/includes/facades.php(28): Valet\Configuration->prune()
#3 /Users/sully/.composer/vendor/laravel/valet/cli/valet.php(43): Facade::__callStatic('prune', Array)
#4 {main}
  thrown in /Users/sully/.composer/vendor/laravel/valet/cli/Valet/Configuration.php on line 202

I tried removing my global packages and reinstalling them and the issue persists:

rm -rf ~/.composer/vendor ~/.composer/composer.lock && composer global update

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 9
  • Comments: 21 (9 by maintainers)

Most upvoted comments

@saleh-mir Three things come up in the responses you posted:

  1. Composer version

composer global diagnose Composer version: 1.8.4 Checking composer version: You are not running the latest stable version, run composer self-update to update (1.8.4 => 1.10.5)

I suggest upgrading composer as they recommend, via: composer self-update

Particularly, I wonder if the older composer version doesn’t work well with PHP 7.4.

  1. dyld library errors

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

This happens after openssl@1.1 gets upgraded.(I saw it after the 1.1.1f and 1.1.1t updates)

The quickest patch I’ve found is to run this:

ln -s /usr/local/Cellar/openssl/1.0.2t/lib/libcrypto.1.0.0.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
ln -s /usr/local/Cellar/openssl/1.0.2t/lib/libssl.1.0.0.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
  1. Other homebrew software versions out of date

curl-openssl 7.69.1 7.64.1 dnsmasq 2.80 nginx 1.17.10

There are newer versions of these available. Running brew upgrade is recommended.

  1. Other dependencies

I also see that your laravel/envoy version in your global composer.json refers to an older version. This may be telling composer to use older constraints than necessary.

  1. Next steps After doing all the above, I was going to suggest composer global update but given the out-of-date envoy version, and the fact that envoy and valet are the only things in your global composer.json, I suggest the following in your case:
composer clear-cache
rm -rf ~/.composer/composer.json ~/.composer/composer.lock ~/.composer/vendor
composer global require laravel/valet
valet install

and then after Valet is working properly composer global require laravel/envoy to put envoy back again.

This solved it for me

composer global remove laravel/valet
composer clear-cache
composer global upgrade
composer global require laravel/valet

@drbyte I did everything you said except step 2 and 4. It’s fixed! Thank you!

newest possible

Yes, but still respecting your current constraints. Adding --with-all-dependencies expands the scope somewhat.

Shoot, apparently the one makes it problem for me was the laravel/envoy, had to do step 5 to get everything back up and running

Thanks for this!