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
> The purpose for that is to allow the end user to configure their own HTTP client, HTTP factories and plugins.
514
+
### HTTP Client (PSR-18) and HTTP Factories (PSR-17)
463
515
464
516
-[HTTP client and HTTP factory adapters](#http-client-and-http-factory-adapters)
465
517
-[Plugin system](#plugin-system)
@@ -525,30 +577,12 @@ class YourApi extends Api
525
577
}
526
578
```
527
579
528
-
The same for the end user:
529
-
530
-
```php
531
-
$api = new YourApi();
532
-
533
-
$client = new Psr18Client();
534
-
$requestFactory = $streamFactory = new Psr17Factory();
535
-
536
-
$api->setClientBuilder(
537
-
new ClientBuilder(
538
-
client: $client,
539
-
requestFactory: $requestFactory,
540
-
streamFactory: $streamFactory
541
-
)
542
-
);
543
-
```
544
-
545
580
#### Plugin System
546
581
547
582
This library enables attaching plugins to the HTTP client.
548
583
A plugin modifies the behavior of the client by intercepting the request and response flow.
549
584
550
-
Since plugin order matters, a plugin is added with a priority level,
551
-
and are executed in descending order from highest to lowest.
585
+
Since plugin order matters, a plugin is added with a priority level, and are executed in descending order from highest to lowest.
552
586
553
587
Check all the [available plugins](https://docs.php-http.org/en/latest/plugins/index.html) or [create your own](https://docs.php-http.org/en/latest/plugins/build-your-own.html).
554
588
@@ -597,23 +631,8 @@ class YourApi extends Api
597
631
}
598
632
```
599
633
600
-
The same for the end user:
601
-
602
-
```php
603
-
$api = new YourApi();
604
-
605
-
$api->getClientBuilder()->addPlugin(
606
-
plugin: new RetryPlugin(['retries' => 3])
607
-
priority: 12
608
-
);
609
-
```
610
-
611
634
### Cache (PSR-6)
612
635
613
-
> [!IMPORTANT]
614
-
> The methods in this section are all public.
615
-
> The purpose for that is to allow the end user to configure their own cache adapter.
616
-
617
636
This library allows configuring the cache layer of the client for making API requests.
618
637
It uses a standard PSR-6 implementation and provides methods to fine-tune how HTTP caching behaves:
0 commit comments