You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Note:** The library automatically selects `StreamingMultipartBuilder` for large files (>1MB by default) to optimize memory usage. You can also manually use it for memory-efficient uploads of any size.
**Performance Note:** The cookie management system automatically optimizes for different workloads. For applications with many cookies (50+), it uses indexed collections with O(1) domain lookups. For smaller cookie counts, it uses simpler collections to minimize overhead.
380
+
381
+
### Event Monitoring
382
+
383
+
Monitor HTTP requests lifecycle with event listeners:
384
+
385
+
```php
386
+
use Farzai\Transport\Events\RequestSendingEvent;
387
+
use Farzai\Transport\Events\ResponseReceivedEvent;
388
+
use Farzai\Transport\Events\RequestFailedEvent;
389
+
use Farzai\Transport\Events\RetryAttemptEvent;
390
+
391
+
$transport = TransportBuilder::make()
392
+
->withBaseUri('https://api.example.com')
393
+
// Track successful responses
394
+
->addEventListener(ResponseReceivedEvent::class, function ($event) {
395
+
printf(
396
+
"[SUCCESS] %s %s → %d (%.2fms)\n",
397
+
$event->getMethod(),
398
+
$event->getUri(),
399
+
$event->getStatusCode(),
400
+
$event->getDuration()
401
+
);
402
+
})
403
+
// Track failed requests
404
+
->addEventListener(RequestFailedEvent::class, function ($event) {
405
+
printf(
406
+
"[ERROR] %s %s failed: %s\n",
407
+
$event->getMethod(),
408
+
$event->getUri(),
409
+
$event->getExceptionMessage()
410
+
);
411
+
})
412
+
// Monitor retry attempts
413
+
->addEventListener(RetryAttemptEvent::class, function ($event) {
414
+
printf(
415
+
"[RETRY] Attempt %d/%d (delay: %dms)\n",
416
+
$event->getAttemptNumber(),
417
+
$event->getMaxAttempts(),
418
+
$event->getDelay()
419
+
);
420
+
})
421
+
->withRetries(3)
422
+
->build();
423
+
424
+
// Events are automatically dispatched during request lifecycle
Copy file name to clipboardExpand all lines: composer.json
+18-4Lines changed: 18 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,21 @@
1
1
{
2
2
"name": "farzai/transport",
3
-
"description": "A HTTP client for Farzai Package",
3
+
"description": "A modern, PSR-compliant HTTP client for PHP with middleware architecture, advanced retry strategies, and fluent API for building requests",
0 commit comments