monolog: PHP Parse error: syntax error, unexpected ‘|', expecting variable (T_VARIABLE)
PHP Parse error: syntax error, unexpected ‘|', expecting variable (T_VARIABLE) in vendor/psr/log/src/LoggerInterface.php on line 30
Diff from v. 2.3.2 to 2.3.4 in LoggerInterface.php
30c30
< public function emergency($message, array $context = array());
---
> public function emergency(string|\Stringable $message, array $context = []): void;
Diff from psr/log v. 1.0.1 and v. 2.0 in composer.json
14c14
< “php”: “>=5.3.0"
---
> “php”: “>=8.0.0"
18c18
< “Psr\\Log\\“: “Psr/Log/”
---
> “Psr\\Log\\“: “src”
23c23
< “dev-master”: “1.1.x-dev”
---
> “dev-master”: “2.0.x-dev”
I’m working with php version 7.4.9, so it appears that the update to using psr/log version 2.0/3.0 which requires php 8.0 is breaking things. Is there a way around this without updating my version of php?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (4 by maintainers)
For laravel, delete the vendor folder, and the composer.lock file and then run composer install. it worked for me
Run composer on PHP 7.4.9 without using
--ignore-platform-reqs, and composer will keep usingpsr/log1.0“php” artisan key:generate PHP Parse error: syntax error, unexpected ‘|’, expecting variable (T_VARIABLE) in C:\xampp\htdocs\laravel-gym-main\vendor\nunomaduro\termwind\src\Functions.php on line 17
can somebody help, what’s wrong with this?
You could explicitly require a version of psr/log in composer.json like 1.1.4
I have the same problem. My hoster can only use 7.3. After I did “composer update”, I got a new monolog update but also psr:
which requires php 8…
my solution for now is I locked monolog in composer.json to “2.2.0”. (before
"^2.2")Thank you so much @glet
"require": { [...] "psr/log": "^1", [...] }did the trick
@microsoftjulius Worked like a champ!! I had upgraded to PHP 8 and Laravel 8 (latest as 2 weeks ago). my program wouldn’t work quite right after the upgrade. (it is integrated into eBay Shopping API for 4 years with Laravel 6 and PHP 7.4
After I upgraded that is when the problems began. thanks for sharing this. I had completely forgotten to do this. it reset everything. I backed up my Vendor folder and composer.json and composer.lock just in case. Wow oh wow, thank you.
@glet Thanks your solution worked for me.
Worked for me. Thanks
there is no reason for monolog to do that. It would the force all users of monolog to use that particular psr/log version (which they will complain about). The current version constraint is working perfectly fine when you use composer properly.