Working:
$users = Http::get('https://random-data-api.com/api/v2/users');
$addresses = Http::get('https://random-data-api.com/api/v2/addresses');
echo($users['id']);
Not Working:
[$users, $addresses] = Octane::concurrently([
fn () => Http::get('https://random-data-api.com/api/v2/users'),
fn () => Http::get('https://random-data-api.com/api/v2/addresses'),
]);
echo($users['id']);
Error:
fseek(): Argument #1 ($stream) must be of type resource, int given
at vendor/guzzlehttp/psr7/src/Stream.php:211
Versions
- php -v
PHP 8.1.23 (cli) (built: Aug 31 2023 19:07:30) (NTS)
- php artisan --version
Laravel Framework 10.24.0
- php -i | grep swoole -1 | grep Version
Version => 5.1.0
print_r($users)
gives back a full Illuminate\Http\Client\Response Object which has the entire GuzzleHttp\Psr7\Response Object.
$users->status()
gives back 200. headers work as well.
However, $users->body() and $users->json()
etc. give back the same error as above.
I can't find any documentation or any tutorial on how to handle multiple Http:get inside Octane::concurrently
. Hope anyone can help me out with this, as I hoped this would be really simple to do so.
All I want to do for this proof of concept is to get back $users['id']
after I did the Octane::concurrently method.