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
Copy file name to clipboardExpand all lines: README.md
+8-11Lines changed: 8 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,30 +10,27 @@ Abstract client-side PHP implementation of the [json api specification](http://j
10
10
composer require enm/json-api-client
11
11
```
12
12
13
-
You can use the default HTTP implementation (`Enm\JsonApi\HttpClient\GuzzleAdapter`) which requires the Guzzle client.
13
+
It's recommended to install `kriswallsmith/buzz` as http-client and `nyholm/psr7` for http factories.
14
14
15
15
```sh
16
-
composer require guzzlehttp/guzzle ^6.0
16
+
composer require kriswallsmith/buzz nyholm/psr7
17
17
```
18
18
19
-
or the BuzzCurlAdapter (`Enm\JsonApi\HttpClient\BuzzCurlAdapter`) which requires the `kriswallsmith/buzz` client.
20
-
21
-
```sh
22
-
composer require kriswallsmith/buzz ^0.16
23
-
```
24
-
25
-
If needed you can also implement the interface by yourself to use any HTTP client which supports PSR-7.
19
+
You can also use any HTTP client which implements [PSR-18](https://www.php-fig.org/psr/psr-18/).
26
20
27
21
## Usage
28
22
First you should read the docs at [enm/json-api-common](https://eosnewmedia.github.io/JSON-API-Common/) where all basic structures are defined.
29
23
30
-
Your API client is an instance of `Enm\JsonApi\Client\JsonApiClient`, which requires a HTTP client (`Enm\JsonApi\HttpClient\HttpClientInterface`) to execute requests.
24
+
Your API client is an instance of `Enm\JsonApi\Client\JsonApiClient`, which requires a PSR-18 HTTP client (`Psr\Http\Client\ClientInterface`) to execute requests.
31
25
32
26
```php
33
27
34
28
$client = new JsonApiClient(
35
29
'http://example.com/api',
36
-
new GuzzleAdapter(new Client()), // with guzzle in this example...
30
+
$httpClient, // instance of Psr\Http\Client\ClientInterface
31
+
$uriFactory, // instance of Psr\Http\Message\UriFactoryInterface
32
+
$requestFactory, // instance of Psr\Http\Message\RequestFactoryInterface
33
+
$streamFactory, // instance of Psr\Http\Message\StreamFactoryInterface
0 commit comments