2

我使用Laravel 8guzzlehttp/guzzle中的包。升级到PHP 8后,我得到:

Symfony\Component\ErrorHandler\Error\FatalError: Invalid opcode 117/2/0. in file ../vendor/defuse/php-encryption/src/Core.php on line 412

作曲家.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如果我opcache_reset ();之前打电话$this->client = new \GuzzleHttp\Client; $response = $this->client->post(...),它的工作原理。

UPD 2 $ service php8.0-fpm reload - 没有帮助。

UPD 3重新启动服务器没有帮助。

我怎样才能解决这个问题?

4

2 回答 2

0

问题不是guzzlehttp/guzzle。问题是,在Ubuntu 20.10 PHP8上没有清除opcache。如果您opcache_reset();在致电之前这样做new \GuzzleHttp\Client;,那么一切正常。

于 2020-11-27T21:27:00.150 回答
0

正如@NikiC 在上面的评论中所说,它实际上是 PHP 中的一个错误。在这里修复:https ://github.com/php/php-src/commit/fdb05b92bfb62906771fd41f3fcdbc184d89e3fe

每次都重置 opcache 不是一个好主意,因为如果你打算这样做,你可能还没有任何 opcache。

于 2020-11-30T21:18:54.787 回答