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?
My Answer:
't have a built-in support for Laravel, but you can easily use Guzzle with Laravel by installing it through Composer. Here's how you can do it:
1. Install Guzzle via Composer by running the following command in your terminal:
composer require guzzlehttp/guzzle
2. Once Guzzle is installed, you can use it in your Laravel application by importing it at the top of your file:
php
use GuzzleHttp\Client;
3. You can then create a new instance of the Guzzle client and make HTTP requests like so:
php
$client = new Client();
$response = $client->request('GET', 'https://api.example.com');
$body = $response->getBody();
$data = json_decode($body);
// Do something with the response data
That's it! You can now use Guzzle to make HTTP requests in your Laravel application.
Rate this post
3 of 5 based on 4998 votesComments