Skip to content

Commit 6df9a8d

Browse files
authored
Merge pull request #22 from linkorb/custom-guzzle
Support custom guzzle client
2 parents 2e545d8 + db33715 commit 6df9a8d

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,36 @@ Btw, we're hiring!
3030
3131
### The client
3232
33+
### Instantiate the client
34+
35+
```php
36+
$client = new Client($server);
37+
```
38+
39+
### Instantiate the client with custom Guzzle Client
40+
41+
```php
42+
$client = Client::constructWithGuzzleClient($guzzleClient, $server);
43+
```
44+
45+
### Use the client instance
3346
```php
34-
$client = new Client($server);
35-
$client->set('/foo', 'fooValue');
36-
// Set the ttl
37-
$client->set('/foo', 'fooValue', 10);
38-
// get key value
39-
echo $client->get('/foo');
40-
41-
// Update value with key
42-
$client->update('/foo', 'newFooValue');
43-
44-
// Delete key
45-
$client->rm('/foo');
46-
47-
// Create a directory
48-
$client->mkdir('/fooDir');
49-
// Remove dir
50-
$client->rmdir('/fooDir');
51-
47+
$client->set('/foo', 'fooValue');
48+
// Set the ttl
49+
$client->set('/foo', 'fooValue', 10);
50+
// get key value
51+
echo $client->get('/foo');
52+
53+
// Update value with key
54+
$client->update('/foo', 'newFooValue');
55+
56+
// Delete key
57+
$client->rm('/foo');
58+
59+
// Create a directory
60+
$client->mkdir('/fooDir');
61+
// Remove dir
62+
$client->rmdir('/fooDir');
5263
```
5364
5465
### The command line tool

src/Client.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ public function __construct($server = '', $version = 'v2')
3939
);
4040
}
4141

42+
public static function constructWithGuzzleClient(GuzzleClient $guzzleClient, $server, $version)
43+
{
44+
$client = new Client($server, $version);
45+
$client->guzzleClient = $guzzleClient;
46+
return $client;
47+
}
48+
4249
/**
4350
* Set the default root directory. the default is `/`
4451
* If the root is others e.g. /linkorb when you set new key,

0 commit comments

Comments
 (0)