Skip to content

Commit

Permalink
Merge pull request #22 from linkorb/custom-guzzle
Browse files Browse the repository at this point in the history
Support custom guzzle client
  • Loading branch information
joostfaassen authored Jun 26, 2018
2 parents 2e545d8 + db33715 commit 6df9a8d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 18 deletions.
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,36 @@ Btw, we're hiring!
### The client
### Instantiate the client
```php
$client = new Client($server);
```
### Instantiate the client with custom Guzzle Client
```php
$client = Client::constructWithGuzzleClient($guzzleClient, $server);
```
### Use the client instance
```php
$client = new Client($server);
$client->set('/foo', 'fooValue');
// Set the ttl
$client->set('/foo', 'fooValue', 10);
// get key value
echo $client->get('/foo');
// Update value with key
$client->update('/foo', 'newFooValue');
// Delete key
$client->rm('/foo');
// Create a directory
$client->mkdir('/fooDir');
// Remove dir
$client->rmdir('/fooDir');
$client->set('/foo', 'fooValue');
// Set the ttl
$client->set('/foo', 'fooValue', 10);
// get key value
echo $client->get('/foo');
// Update value with key
$client->update('/foo', 'newFooValue');
// Delete key
$client->rm('/foo');
// Create a directory
$client->mkdir('/fooDir');
// Remove dir
$client->rmdir('/fooDir');
```
### The command line tool
Expand Down
7 changes: 7 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public function __construct($server = '', $version = 'v2')
);
}

public static function constructWithGuzzleClient(GuzzleClient $guzzleClient, $server, $version)
{
$client = new Client($server, $version);
$client->guzzleClient = $guzzleClient;
return $client;
}

/**
* Set the default root directory. the default is `/`
* If the root is others e.g. /linkorb when you set new key,
Expand Down

0 comments on commit 6df9a8d

Please sign in to comment.