➜ ~ valet
PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /Users/roberto/.composer/vendor/tightenco/collect/src/Illuminate/Support/Collection.php on line 155
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /Users/roberto/.composer/vendor/tightenco/collect/src/Illuminate/Support/Collection.php on line 155
I guess this has to do with Laravel requiring PHP 7+ to work, and since Valet relies on Illuminate, it's breaking.
I'm looking for a way to switch back to PHP 7.1 manually, but in the meantime, I thought I'd let you know.
brew unlink php56 brew link php70 will allow you to switch.
This issue was already fixed. But due to the way composer works you can't downgrade dependencies. The only way to do that is manually removing the ~/.composer folder and reinstalling valet+
Does this mean that switching to php56 doesn't work?
@EHLOVader it does work, just follow the steps I outlined above 👍
I've ran the brew comands above but this error still happens when I try to use valet
Restarting my machine allows valet to switch to php 5.6. No other ways have worked for me. Switching back to 7+ works fine with an unlink/link of php, updating $PATH, sourcing and valet restart
You got error like this because you have vendors for upper php version, all you have to do is downgrade your vendros with composer global update Then you should be able to valet use php (for example). After that run again composer global update to update your vendors for desired php version.
Worked for me.
When the current version of Valet (or Valet Plus) installed on your computer does not support PHP 5.6 on the terminal while switching the PHP version, you get this error. When you execute valet use [email protected] on your terminal, it unlinks the current version of the PHP and links PHP 5.6. So, the PHP which runs on the terminal also becomes PHP 5.6. So, before switching your PHP to a higher version for Valet, run the following command on the terminal (as suggested by @timneutkens):
brew unlink [email protected] && brew link [email protected]
Assuming that the highest version of PHP installed on your computer view Homebrew is PHP 7.4. Otherwise, you can change it accordingly.
Then run the command to switch to any other version of PHP to use with Valet (or Valet Plus). For example:
valet use [email protected]
@nicp0nim's solution does not work.
When the current version of Valet (or Valet Plus) installed on your computer does not support PHP 5.6 on the terminal while switching the PHP version, you get this error. When you execute
valet use [email protected]on your terminal, it unlinks the current version of the PHP and links PHP 5.6. So, the PHP which runs on the terminal also becomes PHP 5.6. So, before switching your PHP to a higher version for Valet, run the following command on the terminal (as suggested by @timneutkens):brew unlink [email protected] && brew link [email protected]Assuming that the highest version of PHP installed on your computer view Homebrew is PHP 7.4. Otherwise, you can change it accordingly.
Then run the command to switch to any other version of PHP to use with Valet (or Valet Plus). For example:
valet use [email protected]@nicp0nim's solution does not work.
For me my solution worked. Becouse i switched from php 7.4 to php 5.6 to work with project that uses lower php version. If i would done your solution i couldnt work with my older project, becouse ive got installed laravel and laravel-zero globally for php 7.4 and composer couldnt update and also valet crashed ;)
You cant do like that if you want to use this lower php version for example to composer globall update. Offcourse if you want switch back to working version it worked couse when u link back brew CLI uses that.
When the current version of Valet (or Valet Plus) installed on your computer does not support PHP 5.6 on the terminal while switching the PHP version, you get this error. When you execute
valet use [email protected]on your terminal, it unlinks the current version of the PHP and links PHP 5.6. So, the PHP which runs on the terminal also becomes PHP 5.6. So, before switching your PHP to a higher version for Valet, run the following command on the terminal (as suggested by @timneutkens):brew unlink [email protected] && brew link [email protected]Assuming that the highest version of PHP installed on your computer view Homebrew is PHP 7.4. Otherwise, you can change it accordingly.
Then run the command to switch to any other version of PHP to use with Valet (or Valet Plus). For example:valet use [email protected]@nicp0nim's solution does not work.
For me my solution worked. Becouse i switched from php 7.4 to php 5.6 to work with project that uses lower php version. If i would done your solution i couldnt work with my older project, becouse ive got installed laravel and laravel-zero globally for php 7.4 and composer couldnt update and also valet crashed ;)
You cant do like that if you want to use this lower php version for example to composer globall update. Offcourse if you want switch back to working version it worked couse when u link back brew CLI uses that.
Worked for me too
Most helpful comment
You got error like this because you have vendors for upper php version, all you have to do is downgrade your vendros with
composer global updateThen you should be able tovalet use php(for example). After that run againcomposer global updateto update your vendors for desired php version.Worked for me.