tenantcloud / guzzle-helper
Guzzle 辅助工具。
v1.5.0
2024-04-25 12:54 UTC
Requires
- php: >=8.2
- ext-json: *
- guzzlehttp/guzzle: ~7.2
- illuminate/support: ^9.0 || ^10.0
- spatie/macroable: 1.0.1
Requires (Dev)
- orchestra/testbench: ^7.0 || ^8.5
- pestphp/pest: ^2.8
- php-cs-fixer/shim: ~3.19.2
- phpstan/phpstan: ~1.10.21
- phpstan/phpstan-mockery: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- phpstan/phpstan-webmozart-assert: ^1.2
- tenantcloud/php-cs-fixer-rule-sets: ~3.0.0
This package is auto-updated.
Last update: 2024-09-14 21:11:03 UTC
README
Guzzle 辅助工具。为 Guzzle 中间件添加头部和 Json 混淆器。用于从响应日志中移除授权头部和敏感数据。
要求
- Guzzle >=7
- PHP 版本 >=7.4.1
- Docker(可选)
安装
在您的 composer.json
文件中添加此存储库
"repositories": [
{
"type": "git",
"url": "https://github.com/tenantcloud/guzzle-helpers"
}
],
然后运行 composer require tenantcloud/guzzle-helpers
安装此包。
示例
$stack = \GuzzleHttp\HandlerStack::create();
// Return all response body.
$stack->unshift(\TenantCloud\GuzzleHelper\GuzzleMiddleware\GuzzleMiddleware::fullErrorResponseBody());
// Hide secret info from error responses (cut contactEmail, contactPhone keys).
// Hide Authorization header
$stack->unshift(\TenantCloud\GuzzleHelper\GuzzleMiddleware\GuzzleMiddleware::dumpRequestBody([
new \TenantCloud\GuzzleHelper\GuzzleMiddleware\JsonObfuscator([
'contactEmail',
'contactPhone',
]),
new \TenantCloud\GuzzleHelper\GuzzleMiddleware\HeaderObfuscator(['Authorization']),
]));
命令
安装依赖项:docker run -it --rm -v $PWD:/app -w /app composer install
运行测试:docker run -it --rm -v $PWD:/app -w /app php:7.4-cli vendor/bin/phpunit
在本地运行 php-cs-fixer:docker run -it --rm -v $PWD:/app -w /app composer cs-fix