ion-bazan/guzzle-bundle-aliyun-signer-plugin

适用于Guzzle Bundle的阿里云API网关请求签名插件 ⛽️

v0.1.0 2020-07-10 14:30 UTC

This package is auto-updated.

Last update: 2024-08-29 05:37:48 UTC


README

Latest version GitHub Workflow Status PHP version Codecov Mutation testing badge Scrutinizer Code Quality Downloads License

描述

此Guzzle Bundle插件将 ion-bazan/aliyun-http-signer 与Symfony集成。

要求

安装

使用 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。