Search code examples
phplaravellaravel-8guzzlephp-8

guzzlehttp/guzzle dosn't work after update php to php 8


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?


Solution

  • 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.