Skip to content

Commit 3058d2f

Browse files
committed
switch from GuzzleHttp to psr 7/17/18
1 parent 03d7fc0 commit 3058d2f

16 files changed

+268
-209
lines changed

README.md

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,55 @@ composer require gnello/php-mattermost-driver:1.*
3232
#### Login id and password
3333
```php
3434
use \Gnello\Mattermost\Driver;
35-
36-
// construct your own GuzzleHttp client instance
37-
$guzzle = new GuzzleHttp/Client(...);
38-
39-
$driver = new Driver($guzzle, [
40-
'url' => 'your_chat_url',
41-
'login_id' => 'your_login_id',
42-
'password' => 'your_password',
43-
]);
35+
use Psr\Http\Client\ClientInterface;
36+
use Psr\Http\Message\RequestFactoryInterface;
37+
use Psr\Http\Message\StreamFactoryInterface;
38+
39+
// construct or discover your own PSR7 instances
40+
/** @var ClientInterface */
41+
$httpClient = ...;
42+
/** @var RequestFactoryInterface */
43+
$requestFactory = ...;
44+
/** @var StreamFactoryInterface */
45+
$streamFactory = ...;
46+
47+
$driver = new Driver(
48+
$httpClient,
49+
$requestFactory,
50+
$streamFactory,
51+
[
52+
'url' => 'your_chat_url',
53+
'login_id' => 'your_login_id',
54+
'password' => 'your_password',
55+
]
56+
);
4457
$result = $driver->authenticate();
4558
```
4659

4760
#### Token
4861
```php
49-
use \Gnello\Mattermost\Driver;
50-
51-
// construct your own GuzzleHttp client instance
52-
$guzzle = new GuzzleHttp/Client(...);
53-
54-
$driver = new Driver($guzzle, [
55-
'url' => 'your_chat_url',
56-
'token' => 'your_token',
57-
]);
62+
use \Gnello\Mattermost\Driver;
63+
use Psr\Http\Client\ClientInterface;
64+
use Psr\Http\Message\RequestFactoryInterface;
65+
use Psr\Http\Message\StreamFactoryInterface;
66+
67+
// construct or discover your own PSR7 instances
68+
/** @var ClientInterface */
69+
$httpClient = ...;
70+
/** @var RequestFactoryInterface */
71+
$requestFactory = ...;
72+
/** @var StreamFactoryInterface */
73+
$streamFactory = ...;
74+
75+
$driver = new Driver(
76+
$httpClient,
77+
$requestFactory,
78+
$streamFactory,
79+
[
80+
'url' => 'your_chat_url',
81+
'token' => 'your_token',
82+
]
83+
);
5884

5985
$result = $driver->authenticate();
6086
```
@@ -198,4 +224,3 @@ Don't you see the endpoint you need? Feel free to open an issue or a PR!
198224
[10]: https://github.com/gnello/laravel-mattermost-driver
199225
[11]: https://poser.pugx.org/gnello/php-mattermost-driver/downloads
200226
[12]: https://packagist.org/packages/gnello/php-mattermost-driver
201-
[13]: https://docs.guzzlephp.org/en/stable/request-options.html

composer.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,27 @@
1717
"require": {
1818
"php": ">=5.5.0",
1919
"ext-json": "*",
20-
"psr/http-message" : "^1.0",
21-
"guzzlehttp/guzzle": "^6.2|^7.4"
20+
"nyholm/psr7": "^1.5",
21+
"psr/http-client": "^1.0",
22+
"psr/http-client-implementation": "^1.0",
23+
"psr/http-message": "^1.0",
24+
"psr/http-message-implementation": "^1.0",
25+
"psr/http-factory": "^1.0",
26+
"psr/http-factory-implementation": "^1.0",
27+
"php-http/multipart-stream-builder": "^1.2"
2228
},
2329
"require-dev": {
24-
"symfony/var-dumper": "^3.1"
30+
"symfony/var-dumper": "^3.1",
31+
"guzzlehttp/guzzle": "^7.5"
2532
},
2633
"autoload": {
2734
"psr-4": {
2835
"Gnello\\Mattermost\\": "src/"
2936
}
37+
},
38+
"config": {
39+
"allow-plugins": {
40+
"php-http/discovery": true
41+
}
3042
}
3143
}

0 commit comments

Comments
 (0)