问题
I use the guzzlehttp/guzzle
package in Laravel 8. After upgrading to PHP 8, I get:
Symfony\Component\ErrorHandler\Error\FatalError: Invalid opcode 117/2/0. in file ../vendor/defuse/php-encryption/src/Core.php on line 412
composer.json:
"require": {
"php": "^8.0",
"doctrine/dbal": "^2.12.1",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^8.12",
"laravel/passport": "^10.0",
"laravel/tinker": "^2.5",
"ext-json": "*"
},
"require-dev": {
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
},
php -v
:
PHP 8.0.0RC3 (cli) (built: Oct 31 2020 17:06:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.0.0RC3, Copyright (c), by Zend Technologies
UPD 1 If I call
opcache_reset ();
before$this->client = new \GuzzleHttp\Client; $response = $this->client->post(...)
, it works.
UPD 2
$ service php8.0-fpm reload
- did not help.
UPD 3 Reboot server did not help.
How can I fix this?
回答1:
The problem is not guzzlehttp/guzzle
. The problem is, on Ubuntu 20.10 PHP8 does not clear the opcache. If you do opcache_reset();
before calling new \GuzzleHttp\Client;
, then everything works.
回答2:
As @NikiC said in the comments above it’s actually a bug in PHP. Fix here: https://github.com/php/php-src/commit/fdb05b92bfb62906771fd41f3fcdbc184d89e3fe
It is NOT a good idea to reset the opcache each time as you may as well not have any opcache if you are going to do that.
来源:https://stackoverflow.com/questions/65033643/guzzlehttp-guzzle-dosnt-work-after-update-php-to-php-8