Download the PHP package m6web/guzzle-http-bundle without Composer
On this page you can find all versions of the php package m6web/guzzle-http-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download m6web/guzzle-http-bundle
More information about m6web/guzzle-http-bundle
Files in m6web/guzzle-http-bundle
Package guzzle-http-bundle
Short Description Symfony bundle on top of Guzzle
License MIT
Informations about the package guzzle-http-bundle
GuzzleHttpBundle
The GuzzleHttpBundle provide Guzzle clients as Symfony services.
Installation
Require the bundle with Composer:
For older Symfony versions, you can try to install an older version of this bundle.
If you don't use Symfony Flex, register the bundle in your kernel:
Usage
Add the m6web_guzzlehttp
section in your configuration file. Here is the minimal configuration required.
All subkey under clients defines an instance of guzzle http client. These services are named m6web_guzzlehttp_
+subkey expect for the
default
subkey that define the main service m6web_guzzlehttp
.
Then you can ask container for your client:
The service return a configured guzzle client, for more information on how to use it, you can read the guzzle6 documentation.
The only difference with guzzle6 reside in usage of curl for the redirect responses. You can choose to have the guzzle behavior
for redirection by setting the configuration key redirect_handler
to guzzle
.
When a cache system is available, you can use cache_force
and cache_ttl
in addition of guzzle options than respectively
force clear cache before request and use a specific ttl to a request that override configuration.
DataCollector
A data collector is available when the Symfony profiler is enabled.
It allows you to inspect the following data:
- Method
- Url
- Response code and reason
- Execution time
- Redirect count
- Redirect time
- Cache hit
- Cache TTL
NOTE: If you choose Guzzle for redirect_handler
, The redirect count and redirect time will always be zero.
Cache information are available when a cache system is set.
Cache system
You can set a cache for request by adding in the config the guzzlehttp_cache
with service
subkey who is a reference
to a service implementing M6Web\Bundle\GuzzleHttpBundle\Cache\CacheInterface
We provide an "In memory" cache class that you can use by defining a new cache service and use it in Guzzle configuration:
We also provide a cache interface for Redis with our RedisBundle >= 2.4, than you can use in this way:
For more information on how to set up the RedisBundle, refer to the README in the project.
We provide also the same cache system for APCU through the ApcuBundle.
Configuration reference
As some configuration options accept multiples data types, all services references must start with a @
character.
For the headers
options, the key in array represent the header name. The underscore will be transformed to hyphen except if it's escaped by a backslash.
Adding a middleware
Implement M6Web\Bundle\GuzzleHttpBundle\Middleware\MiddlewareInterface
.
Tag your service with m6web_guzzlehttp.middleware
and specify the client as follows:
Contributing
First, thank you for contributing!
Here are few rules to follow for an easier code review before the maintainers accept and merge your pull request:
- you MUST write or update tests
- you MUST write or update documentation
- the CI must pass on your pull request
Running the test
Install the composer dev dependencies
Then run the test with atoum unit test framework
All versions of guzzle-http-bundle with dependencies
ext-curl Version *
guzzlehttp/guzzle Version ^7
symfony/config Version ^5.4||^6.0
symfony/dependency-injection Version ^5.4||^6.0
symfony/event-dispatcher Version ^5.4||^6.0
symfony/http-kernel Version ^5.4||^6.0
symfony/yaml Version ^5.4||^6.0