Closed php-writerman closed 2 years ago
See #122. Some of the symfony polyfills contain union types, which are compatible only with PHP8.
@mauricius Thanks, it solved the issue.
Followed the way provided in #122 , but it didn't work. Does anyone have any ideas? Thanks all .
Illuminate\Http\Client\RequestException HTTP request returned status code 500: at vendor/laravel/framework/src/Illuminate/Http/Client/Response.php:231
Laravel 8 PHP 7.4
The problem still remains.
Laravel 8.45.1 PHP 7.4.18
This does not help:
'exclude' => [ ... ... 'symfony/polyfill-ctype', 'symfony/polyfill-iconv', 'symfony/polyfill-intl-grapheme', 'symfony/polyfill-intl-idn', 'symfony/polyfill-intl-normalizer', 'symfony/polyfill-mbstring', 'symfony/polyfill-php80' ],
symfony/console
and symfony/event-dispatcher
contain PHP8-only compatible classes and they are installed even in PHP7.4 environments.
The following works for me in Laravel 8.47
'exclude' => [
'symfony/console',
'symfony/event-dispatcher',
'symfony/polyfill-ctype',
'symfony/polyfill-iconv',
'symfony/polyfill-intl-grapheme',
'symfony/polyfill-intl-idn',
'symfony/polyfill-intl-normalizer',
'symfony/polyfill-mbstring',
'symfony/polyfill-php80'
],
If you still have issues you can try to exclude the entire symfony folder:
'exclude' => [
'symfony'
],
@mauricius Please see the comment It happens even when adding 'symfony' to 'exclude'
I ran into this issue yesterday. We're running Laravel 8 on PHP7.4.
What I discovered is that Doctrine/Common contains PHP8 code. Specifically Doctrine\Common\Cache\Psr6\TypedCacheItem
.
Within your opcache.php
, add into your exclude list Doctrine/Common/Cache/Psr6
. Be certain to clear and rebuild your caches afterwards.
I thought it might be helpful to document how I found this because the thrown exception is not immediately helpful.
When the exception occurs, it points to line 258 of Illuminate\Http\Client\Response
.
public function toException()
{
if ($this->failed()) {
return new RequestException($this); < Go into RequestException.
}
}
Within RequestException::prepareMessage()
you'll see on line 37 that it's getting the $summary
. There is an available second argument to both \GuzzleHttp\Psr7\Message::bodySummary()
and \GuzzleHttp\Psr7\get_message_body_summary()
called $truncatedAt
and it defaults to 120.
Up this number, rerun php artisan opcache:compile --force
and you will then see the rest of the exception message and it will point you to your problem.
Hope that helps.
UPDATE: You can add symfony/service-contracts
to the excludes list.
UPDATE: You can get more fine grained with this:
'exclude' => [
'symfony/console/Attribute',
'symfony/event-dispatcher/Attribute',
'symfony/polyfill-ctype', // bootstrap80.php is the offender here. Can't seem to exclude files. Only folders. This follows all the way down to symfony/polyfill-php80
'symfony/polyfill-iconv',
'symfony/polyfill-intl-grapheme',
'symfony/polyfill-intl-idn',
'symfony/polyfill-intl-normalizer',
'symfony/polyfill-mbstring',
'symfony/polyfill-php80',
'symfony/service-contracts/Attribute',
'Doctrine/Common/Cache/Psr6',
],
@markkasaboski Unfortunately, it didn't help
@php-writerman See the line "ParseError: syntax error, unexpected identifier "enum" in file (truncated)"?
You need to untruncate this line in order to see the rest of the error message. Once you can see the full error message, you will find the file, and therefore, the package with the offending code. What I described above will help you pinpoint the file.
Go into vendor/laravel/framework/src/Illuminate/Http/Client/RequestException.php
and look for the function prepareMessage()
. Within that function, you'll see a ternary for initializing the $summary variable:
$summary = class_exists(\GuzzleHttp\Psr7\Message::class)
? \GuzzleHttp\Psr7\Message::bodySummary($response->toPsrResponse())
: \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse());
Both of those functions take an integer as a second argument. Assuming your installation does have \GuzzleHttp\Psr7\Message
, do the following:
$summary = class_exists(\GuzzleHttp\Psr7\Message::class)
? \GuzzleHttp\Psr7\Message::bodySummary($response->toPsrResponse(), 50000)
: \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse());
Otherwise add 50000
as the second argument to the other one: \GuzzleHttp\Psr7\get_message_body_summary($response->toPsrResponse(), 50000)
Rerun compile and dig through that output for the file that's producing the error. If you're not sure what to look for, paste it here and I'll take a look.
This may happen several times until you've excluded all of the offenders.
@markkasaboski Thanks a lot! The problem was in some package. I excluded it and now it works.
Issue still here.
Hi, I have same quesiton too, but I solved it. Maybe you can try set APP_URL
and OPCACHE_URL
in .env
.
Then execute php artisan:clear
working! Hope help to you!
Just for Docker (Nginx proxy to Apache)
Nope.
When I added OPACHE_URL=http://localhost
or even 127.0.0.1 in my .env
file and run
$ php8.1 artisan opcache:compile --force
Compiling scripts...
Illuminate\Http\Client\RequestException
HTTP request returned status code 404:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width= (truncated...)
at vendor/laravel/framework/src/Illuminate/Http/Client/Response.php:288
284▕ */
285▕ public function toException()
286▕ {
287▕ if ($this->failed()) {
➜ 288▕ return new RequestException($this);
289▕ }
290▕ }
291▕
292▕ /**
+15 vendor frames
16 artisan:37
Illuminate\Foundation\Console\Kernel::handle()
So it still aren't resolution.
More info for debugging that issue.
I have opcache.dups_fix
enabled and run:
$ php8.1 artisan opcache:compile --force
and get:
[2022-11-24 00:27:17] stg.ERROR: HTTP request returned status code 500 {"exception":"[object] (Illuminate\\Http\\Client\\RequestException(code: 500): HTTP request returned status code 500 at /data/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/Response.php:302)
[stacktrace]
#0 /data/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/Response.php(319): Illuminate\\Http\\Client\\Response->toException()
#1 /data/www/html/vendor/appstract/laravel-opcache/src/Commands/Compile.php(34): Illuminate\\Http\\Client\\Response->throw()
#2 /data/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Appstract\\Opcache\\Commands\\Compile->handle()
#3 /data/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#4 /data/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()
#5 /data/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()
#6 /data/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Container\\BoundMethod::call()
#7 /data/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(178): Illuminate\\Container\\Container->call()
#8 /data/www/html/vendor/symfony/console/Command/Command.php(308): Illuminate\\Console\\Command->execute()
#9 /data/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(148): Symfony\\Component\\Console\\Command\\Command->run()
#10 /data/www/html/vendor/symfony/console/Application.php(1014): Illuminate\\Console\\Command->run()
#11 /data/www/html/vendor/symfony/console/Application.php(301): Symfony\\Component\\Console\\Application->doRunCommand()
#12 /data/www/html/vendor/symfony/console/Application.php(171): Symfony\\Component\\Console\\Application->doRun()
#13 /data/www/html/vendor/laravel/framework/src/Illuminate/Console/Application.php(102): Symfony\\Component\\Console\\Application->run()
#14 /data/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(155): Illuminate\\Console\\Application->run()
#15 /data/www/html/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#16 {main}
"}
Running php artisan opcache:compile I receive: `ParseError: syntax error, unexpected '|', expecting variable (T_VARIABLE) (truncated...)
at vendor/laravel/framework/src/Illuminate/Http/Client/Response.php:241 237▕ { 238▕ $callback = func_get_args()[0] ?? null; 239▕ 240▕ if ($this->failed()) { ➜ 241▕ throw tap(new RequestException($this), function ($exception) use ($callback) { 242▕ if ($callback && is_callable($callback)) { 243▕ $callback($this, $exception); 244▕ } 245▕ }); `
Laravel 8.22.1 PHP 7.4.14