Skip to content

Commit ea3b4f8

Browse files
committed
require all necessary psr implementations
the code relies on psr7, psr17 and psr18 implementations to be available, with the discovery. it no longer uses the php-http httplug interface (which was made obsolete by psr-18). php-http/client-common is also not used in the code.
1 parent 9fb6b8a commit ea3b4f8

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

README.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@ There are two ways to use MailerLite PHP SDK:
1414

1515
If you are not familiar with Composer, learn about it [here](https://getcomposer.org/doc/01-basic-usage.md).
1616

17-
Then you will need to run this simple command using CLI:
18-
19-
```
20-
composer require mailerlite/mailerlite-api-v2-php-sdk
21-
```
22-
2317
This library is built atop of [PSR-7](https://www.php-fig.org/psr/psr-7/) and
24-
[PSR-18](https://www.php-fig.org/psr/psr-18/). If you are receiving `Http\Discovery\Exception\DiscoveryFailedException` exception, you will need to run:
18+
[PSR-18](https://www.php-fig.org/psr/psr-18/).
19+
20+
To install the library, you also need to choose an HTTP client implementation. To install the mailerlite with guzzle, run this command line:
2521

26-
```bash
27-
composer require php-http/guzzle6-adapter
22+
```
23+
composer require mailerlite/mailerlite-api-v2-php-sdk guzzlehttp/guzzle
2824
```
2925

3026
##### Manual (preferable for shared hostings)

composer.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
"type": "library",
88
"require": {
99
"php" : "^7.1 || ^8.0",
10-
"php-http/client-common": "^2.0",
10+
"psr/http-message-implementation": "*",
11+
"psr/http-factory-implementation": "*",
12+
"psr/http-client-implementation": "*",
1113
"php-http/discovery": "^1.7",
12-
"nyholm/psr7": "^1.0",
1314
"ext-json": "*"
1415
},
1516
"require-dev": {
16-
"php-http/guzzle6-adapter": "^2.0",
17+
"guzzlehttp/guzzle": "^7.0",
1718
"phpunit/phpunit": "6.* | 7.* | 8.* | 9.*"
1819
},
1920
"autoload": {
@@ -25,5 +26,8 @@
2526
"psr-4": {
2627
"MailerLiteApi\\Tests\\": "tests/"
2728
}
29+
},
30+
"conflict": {
31+
"php-http/httplug": "< 2"
2832
}
2933
}

src/Common/RestClient.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace MailerLiteApi\Common;
44

5-
use Http\Client\HttpClient;
65
use Http\Discovery\Psr17FactoryDiscovery;
76
use Http\Discovery\Psr18ClientDiscovery;
87
use Psr\Http\Client\ClientInterface;
@@ -25,9 +24,9 @@ class RestClient {
2524
/**
2625
* @param string $baseUrl
2726
* @param string $apiKey
28-
* @param \Http\Client\HttpClient|null $httpClient
27+
* @param ClientInterface|null $httpClient
2928
*/
30-
public function __construct($baseUrl, $apiKey, HttpClient $httpClient = null)
29+
public function __construct($baseUrl, $apiKey, ClientInterface $httpClient = null)
3130
{
3231
$this->baseUrl = $baseUrl;
3332
$this->apiKey = $apiKey;

src/MailerLite.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
namespace MailerLiteApi;
44

5-
use Http\Client\HttpClient;
6-
75
use MailerLiteApi\Common\ApiConstants;
86
use MailerLiteApi\Common\RestClient;
97
use MailerLiteApi\Exceptions\MailerLiteSdkException;
8+
use Psr\Http\Client\ClientInterface;
109

1110
/**
1211
* Class MailerLite
@@ -27,11 +26,11 @@ class MailerLite {
2726

2827
/**
2928
* @param string|null $apiKey
30-
* @param HttpClient $client
29+
* @param ClientInterface|null $client
3130
*/
3231
public function __construct(
3332
$apiKey = null,
34-
HttpClient $httpClient = null
33+
ClientInterface $httpClient = null
3534
) {
3635
if (is_null($apiKey)) {
3736
throw new MailerLiteSdkException("API key is not provided");

0 commit comments

Comments
 (0)