doppiogancio / guzzle-bundle-base-path-plugin
A Plugin for Guzzle Bundle, that will help you setting a base path to each request of your client.
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
A Plugin for Guzzle Bundle, that will help you to set a base path to each request of your client.
Prerequisites
- PHP 7.1 or above
Installation
To install this bundle, run the command below on the command line and you will get the latest stable version from [Packagist][4].
composer require doppiogancio/guzzle-bundle-base-path
Usage
Enable bundle
Find next lines in src/Kernel.php
:
foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); } }
and replace them by:
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(); } } }
Basic configuration
# 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"
Options
License
This middleware is licensed under the MIT License - see the LICENSE file for details