doppiogancio / guzzle-bundle-base-path-plugin
一个Guzzle Bundle插件,可帮助您为客户端的每个请求设置基本路径。
v1.0.0
2023-11-01 16:58 UTC
Requires
- php: ^7.1|^8.0
- eightpoints/guzzle-bundle: ^8.0
- guzzlehttp/guzzle: ^6.0|^7.0
- symfony/config: ^4.0|^5.0|^6.0
- symfony/dependency-injection: ^4.0|^5.0|^6.0
- symfony/expression-language: ^4.0|^5.0|^6.0
- symfony/http-kernel: ^4.0|^5.0|^6.0
Requires (Dev)
- ext-json: *
- doppiogancio/mocked-client: ^3.1.11
- php-coveralls/php-coveralls: ^2.2
- php-http/discovery: ^1.19
- phpunit/phpunit: ^9.5
- psr/http-factory-implementation: *
README
一个Guzzle Bundle插件,可帮助您为客户端的每个请求设置基本路径。
先决条件
- PHP 7.1或更高版本
安装
要安装此包,请在命令行中运行以下命令,您将从[Packagist][4]获取最新稳定版本。
composer require doppiogancio/guzzle-bundle-base-path
用法
启用包
在src/Kernel.php
中找到以下行
foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); } }
并将它们替换为
foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { if ($class === \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class) { yield new $class([ new Doppiogancio\Bundle\GuzzleBundleBasePathPlugin\GuzzleBundleBasePathPlugin(), ]); } else { yield new $class(); } } }
基本配置
# app/config/config.yml eight_points_guzzle: clients: api_payment: base_url: "http://api.domain.tld" options: auth: oauth2 # plugin settings plugin: base_path: base_path: "/api/v3"
选项
许可
此中间件采用MIT许可 - 有关详细信息,请参阅LICENSE文件。