Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require all necessary psr implementations #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ There are two ways to use MailerLite PHP SDK:

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

Then you will need to run this simple command using CLI:

```
composer require mailerlite/mailerlite-api-v2-php-sdk
```

This library is built atop of [PSR-7](https://www.php-fig.org/psr/psr-7/) and
[PSR-18](https://www.php-fig.org/psr/psr-18/). If you are receiving `Http\Discovery\Exception\DiscoveryFailedException` exception, you will need to run:
[PSR-18](https://www.php-fig.org/psr/psr-18/).

To install the library, you also need to choose an HTTP client implementation. To install the mailerlite with guzzle, run this command line:

```bash
composer require php-http/guzzle6-adapter
```
composer require mailerlite/mailerlite-api-v2-php-sdk guzzlehttp/guzzle
```

##### Manual (preferable for shared hostings)
Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
"type": "library",
"require": {
"php" : "^7.1 || ^8.0",
"php-http/client-common": "^2.0",
"psr/http-message-implementation": "*",
"psr/http-factory-implementation": "*",
"psr/http-client-implementation": "*",
"php-http/discovery": "^1.7",
"nyholm/psr7": "^1.0",
"ext-json": "*"
},
"require-dev": {
"php-http/guzzle6-adapter": "^2.0",
"guzzlehttp/guzzle": "^7.0",
"phpunit/phpunit": "6.* | 7.* | 8.* | 9.*"
},
"autoload": {
Expand All @@ -25,5 +26,8 @@
"psr-4": {
"MailerLiteApi\\Tests\\": "tests/"
}
},
"conflict": {
"php-http/httplug": "< 2"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this conflict to be sure to not break for users who provide their own httplug client implementation. the httplug 2.* interface extends the psr-18 interface to be compatible with both.

}
}
5 changes: 2 additions & 3 deletions src/Common/RestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace MailerLiteApi\Common;

use Http\Client\HttpClient;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use Psr\Http\Client\ClientInterface;
Expand All @@ -25,9 +24,9 @@ class RestClient {
/**
* @param string $baseUrl
* @param string $apiKey
* @param \Http\Client\HttpClient|null $httpClient
* @param ClientInterface|null $httpClient
*/
public function __construct($baseUrl, $apiKey, HttpClient $httpClient = null)
public function __construct($baseUrl, $apiKey, ClientInterface $httpClient = null)
{
$this->baseUrl = $baseUrl;
$this->apiKey = $apiKey;
Expand Down
7 changes: 3 additions & 4 deletions src/MailerLite.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace MailerLiteApi;

use Http\Client\HttpClient;

use MailerLiteApi\Common\ApiConstants;
use MailerLiteApi\Common\RestClient;
use MailerLiteApi\Exceptions\MailerLiteSdkException;
use Psr\Http\Client\ClientInterface;

/**
* Class MailerLite
Expand All @@ -27,11 +26,11 @@ class MailerLite {

/**
* @param string|null $apiKey
* @param HttpClient $client
* @param ClientInterface|null $client
*/
public function __construct(
$apiKey = null,
HttpClient $httpClient = null
ClientInterface $httpClient = null
) {
if (is_null($apiKey)) {
throw new MailerLiteSdkException("API key is not provided");
Expand Down