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)
@@ -502,7 +554,6 @@ If you don't want to rely on the discovery of implementations, you can set the o
502
554
```php
503
555
use ProgrammatorDev\Api\Api;
504
556
use ProgrammatorDev\Api\Builder\ClientBuilder;
505
-
use Http\Client\Common\EmulatedHttpAsyncClient
506
557
use Symfony\Component\HttpClient\Psr18Client;
507
558
use Nyholm\Psr7\Factory\Psr17Factory;
508
559
@@ -526,30 +577,12 @@ class YourApi extends Api
526
577
}
527
578
```
528
579
529
-
The same for the end user:
530
-
531
-
```php
532
-
$api = new YourApi();
533
-
534
-
$client = new Psr18Client();
535
-
$requestFactory = $streamFactory = new Psr17Factory();
536
-
537
-
$api->setClientBuilder(
538
-
new ClientBuilder(
539
-
client: $client,
540
-
requestFactory: $requestFactory,
541
-
streamFactory: $streamFactory
542
-
)
543
-
);
544
-
```
545
-
546
580
#### Plugin System
547
581
548
582
This library enables attaching plugins to the HTTP client.
549
583
A plugin modifies the behavior of the client by intercepting the request and response flow.
550
584
551
-
Since plugin order matters, a plugin is added with a priority level,
552
-
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.
553
586
554
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).
555
588
@@ -598,23 +631,8 @@ class YourApi extends Api
598
631
}
599
632
```
600
633
601
-
The same for the end user:
602
-
603
-
```php
604
-
$api = new YourApi();
605
-
606
-
$api->getClientBuilder()->addPlugin(
607
-
plugin: new RetryPlugin(['retries' => 3])
608
-
priority: 12
609
-
);
610
-
```
611
-
612
634
### Cache (PSR-6)
613
635
614
-
> [!IMPORTANT]
615
-
> The methods in this section are all public.
616
-
> The purpose for that is to allow the end user to configure their own cache adapter.
617
-
618
636
This library allows configuring the cache layer of the client for making API requests.
619
637
It uses a standard PSR-6 implementation and provides methods to fine-tune how HTTP caching behaves:
0 commit comments