Skip to content

Instantly share code, notes, and snippets.

View Luxato's full-sized avatar
🎯
Focusing

Lukas S. Luxato

🎯
Focusing
  • Denmark
View GitHub Profile
@Luxato
Luxato / guzzle_pool_example.php
Created February 23, 2022 12:28 — forked from wzed/guzzle_pool_example.php
GuzzleHttp\Pool example: identifying responses to concurrent async requests
<?php
/*
* Using a key => value pair with the yield keyword is
* the cleanest method I could find to add identifiers or tags
* to asynchronous concurrent requests in Guzzle,
* so you can identify which response is from which request!
*/
$client = new GuzzleHttp\Client(['base_uri' => 'http://httpbin.org']);
@Luxato
Luxato / concurrent-pool.php
Created February 22, 2022 13:08 — forked from fgilio/concurrent-pool.php
Laravel HTTP client concurrent requests pool
<?php
// 1. Register the routes
Route::get('test/{lorem}', function ($lorem) {
sleep(3);
return response()->json([
'message' => $lorem,
'token' => Str::random(),
]);