Skip to content

Commit

Permalink
Merge pull request #3 from CubeQuence/update/replace_guzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Castelnuovo authored Apr 8, 2021
2 parents 2fdae1d + c641530 commit 7ee7ff7
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 253 deletions.
45 changes: 2 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,9 @@ PHP8 HashiCorp Vault client

1. `composer require cubequence/vault`

## Demo Code
```php
<?php
## Example

require './vendor/autoload.php';

// https://www.vaultproject.io/api-docs/auth
// https://www.vaultproject.io/api-docs/secret

use CQ\Vault\Auth\Provider\AppRole;
use CQ\Vault\Auth\Provider\Token;
use CQ\Vault\Client;

try {
$tokenProvider = new Token(token: 's.XXXXXXXXXXXX');
$approleProvider = new AppRole(
roleId: 'XXXXXX-XXXXXX-XXXXXX-XXXXXX',
secretId: 'XXXXXX-XXXXXX-XXXXXX-XXXXXX'
);

$client = new Client(
authProvider: $tokenProvider,
baseUri: 'http://127.0.0.1:8200',
version: 'v1' // Optional variable
);

$write = $client->write('/kv1/helloworld', [
'foo' => 'bar',
]);
$read = $client->read('/kv1/helloworld');
$keys = $client->keys('/kv1');
$revoke = $client->revoke('/kv1/helloworld');
} catch (\Throwable $th) {
echo $th->getMessage();
exit;
}

echo json_encode([
"write" => $write, // NoContent
"read" => $read,
"keys" => $keys,
"revoke" => $revoke, // NoContent
]);
```
Look at the `examples` folder

## Security Vulnerabilities

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": ">=8.0.0",
"guzzlehttp/guzzle": "^7.0"
"cubequence/request": "^1.0"
},
"require-dev": {
"nunomaduro/phpinsights": "dev-master",
Expand Down
Loading

0 comments on commit 7ee7ff7

Please sign in to comment.