Goutte icon indicating copy to clipboard operation
Goutte copied to clipboard

syntax error, unexpected token ")"

Open BenOussama180 opened this issue 3 years ago • 9 comments

This is the Error i get while creating a new instance of the Client : image It works locally, but not in production. i use php 8.1 locally & 8.0.19 in prod so it should not be a syntax probleme. when i checked prod's laravel logs it says this : [2022-06-22 14:22:19] local.ERROR: syntax error, unexpected token ")" {"userId":2,"exception":"[object] (ParseError(code: 0): syntax error, unexpected token ")" at /home/749128.cloudwaysapps.com/maxxhthfnk/public_html/vendor/symfony/http-client/CurlHttpClient.php:68)

BenOussama180 avatar Jun 23 '22 08:06 BenOussama180

i use php 8.1 locally & 8.0.19 in prod so it should not be a syntax probleme.

Have you configured composer to resolve dependencies for PHP 8.0 ? If no, I'm almost sure that Composer installed symfony/http-client 6.1, which requires PHP 8.1 (and uses the first-class callable syntax)

stof avatar Jun 23 '22 08:06 stof

Oh, i didnt know that, and how should i do that please @stof

BenOussama180 avatar Jun 23 '22 08:06 BenOussama180

https://getcomposer.org/doc/06-config.md#platform

stof avatar Jun 23 '22 08:06 stof

https://getcomposer.org/doc/06-config.md#platform

Thanks alot, and what version of http-client should i install please? @stof

BenOussama180 avatar Jun 23 '22 08:06 BenOussama180

Composer will select the version compatible with the target PHP version (that's why it is important to tell it about the target if the runtime you use is not the target version).

stof avatar Jun 23 '22 09:06 stof

so i should dump autoload after i add the platform under the config ?

BenOussama180 avatar Jun 23 '22 09:06 BenOussama180

you need to run composer update, to resolve dependencies again with the right target.

stof avatar Jun 23 '22 10:06 stof

@stof @BenOussama180 i run the composer update but same issue i m using php 8.0

rajivartifex avatar Feb 21 '23 04:02 rajivartifex

@stof @BenOussama180 i run the composer update but same issue i m using php 8.0

i used spatie crawler which uses goute under the hood and i got no problem with it, i advice u to use it

BenOussama180 avatar Feb 21 '23 04:02 BenOussama180