ion-bazan / guzzle-bundle-aliyun-signer-plugin
适用于Guzzle Bundle的阿里云API网关请求签名插件 ⛽️
v0.1.0
2020-07-10 14:30 UTC
Requires
- php: >=7.2
- eightpoints/guzzle-bundle: ^8.0.1
- ion-bazan/aliyun-http-signer: ^0.2 || ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- infection/infection: ~0.15
- phpunit/phpunit: ^8.0 || ^9.0
This package is auto-updated.
Last update: 2024-08-29 05:37:48 UTC
README
描述
此Guzzle Bundle插件将 ion-bazan/aliyun-http-signer 与Symfony集成。
要求
- PHP 7.2或更高版本
- Guzzle Bundle
安装
使用 Composer 通过以下命令安装插件:
composer require ion-bazan/guzzle-bundle-aliyun-signer-plugin
使用方法
启用Bundle
Symfony 2.x和3.x
在 app/AppKernel.php
文件中注册bundle
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([ new IonBazan\Bundle\GuzzleBundleAliyunSignerPlugin\AliyunRequestSignerPlugin(), ]);
Symfony 4+
要在Symfony 4及更高版本中注册插件,请替换 src/Kernel.php
中的 registerBundles()
方法
public function registerBundles(): iterable { $contents = require $this->getProjectDir().'/config/bundles.php'; foreach ($contents as $class => $envs) { if ($envs[$this->environment] ?? $envs['all'] ?? false) { if ($class === \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class) { yield new $class([ new \IonBazan\Bundle\GuzzleBundleAliyunSignerPlugin\AliyunRequestSignerPlugin(), ]); } else { yield new $class(); } } } }
配置
# config/packages/eight_points_guzzle.yaml eight_points_guzzle: clients: my_client: base_url: "http://target.url" plugin: aliyun_signer: app_id: 'Your AppID' secret: 'Your Secret'
错误 & 问题
如果您发现错误或安全漏洞,请 打开一个问题
贡献
请随时提交Pull Requests以添加新功能或修复错误。
请注意,代码必须遵循PSR-1、PSR-2、PSR-4和PSR-7。