hashicorp保管库服务的PHP客户库。该客户端遵循与Hashicorp Vault客户端文档相等的请求和响应数据。
请随时打开拉动请求以添加改进或缺少功能。
composer require mittwald/vault-php
// setting up independent http client
$ httpClient = new Client ();
// setting up vault auth provider
$ auth = new Token ( ' foo ' );
// creating the vault request client
$ client = new VaultClient (
$ httpClient ,
$ auth ,
' http://127.0.0.1:8200 '
);
// selecting the desired secret engine
// e.g. Transit Secret Engine
$ api = new Transit ( $ client );
// calling specific endpoint
$ response = $ api -> listKeys ();
//reading results
var_dump ( $ response -> getKeys ());
//...
//...
//Profit... public function __construct(
HttpClient $ httpClient ,
AuthenticationProviderInterface $ authProvider ,
string $ apiHost
) HttpClient采用每个符合PSR-18的HTTP客户端适配器,例如"php-http/curl-client": "^1.7"
来自/authentication/provider/* Authentication ProviderFace AuthenticationProviderInterface Authentication提供商
$apiHost HASHICORP VAULT REST端点URL
使用批量请求还需要通过响应和每个批量项目的MetaData拨打hasErrors进行迭代,以确保成功处理。
呼叫库方法将抛出异常,表明在提供无效的数据或发生HTTP错误或遇到Vault Generic端点错误的位置。
VaultException
通用根异常,此库中的每个异常都从。
VaultHttpException
当HTTP处理中的某些内容会导致错误时,将会抛出异常。
VaultAuthenticationException
当API端点身份验证失败时,将抛出。
VaultResponseException
将在5xx状态代码错误上抛出。
InvalidRouteException
调用无效/非现有/禁用的Vault API端点将引发此异常。
InvalidDataException
异常表示失败的服务器有效负载验证。
KeyNameNotFoundException
当尝试请求API端点时,将被抛弃,其中关键名称(在URL中指示)将不存在。