Download the PHP package eightpoints/guzzle-bundle without Composer
On this page you can find all versions of the php package eightpoints/guzzle-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eightpoints/guzzle-bundle
More information about eightpoints/guzzle-bundle
Files in eightpoints/guzzle-bundle
Package guzzle-bundle
Short Description Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony. Comes with easy and powerful configuration options and optional plugins.
License MIT
Homepage https://github.com/8p/GuzzleBundle
Informations about the package guzzle-bundle
Prerequisites | Installation | Configuration | Usage | Plugins | Events | Features | Suggestions | Contributing | Learn more | License
EightPoints GuzzleBundle for Symfony
This bundle integrates Guzzle 6.x|7.x into Symfony. Guzzle is a PHP library for building RESTful web service clients.
GuzzleBundle follows semantic versioning. Read more on semver.org.
Prerequisites
- PHP 7.1 or higher
- Symfony 5.x or 6.x or 7.x
Installation
Installing the bundle
To install this bundle, run the command below on the command line and you will get the latest stable version from Packagist.
Note: this bundle has a Symfony Flex Recipe to automatically register and configure this bundle into your symfony application.
If your project does not use Symfony Flex the following needs to be added to config/bundles.php
manually:
Configuration
Guzzle clients can be configured in config/packages/eight_points_guzzle.yaml
. For projects that use Symfony Flex this file is created
automatically upon installation of this bundle. For projects that don't use Symfony Flex this file should be created manually.
Please refer to the Configuration Reference for a complete list of all options.
Usage
Guzzle clients configured through this bundle are available in the Symfony Dependency Injection container under the name
eight_points_guzzle.client.<name of client>
. So for example a client configured in the configuration with name payment
is available
as eight_points_guzzle.client.payment
.
Suppose you have the following controller that requires a Guzzle Client:
Using manual wiring this controller can be wired as follows:
For projects that use autowiring, please refer to our documentation on autowiring.
Plugins
This bundle allows to register and integrate plugins to extend functionality of guzzle and this bundle.
Installation
In order to install a plugin, find the following lines in src/Kernel.php
:
and replace them with the following:
Known and Supported Plugins
- gregurco/GuzzleBundleWssePlugin
- gregurco/GuzzleBundleCachePlugin
- gregurco/GuzzleBundleOAuth2Plugin
- neirda24/GuzzleBundleHeaderForwardPlugin
- neirda24/GuzzleBundleHeaderDisableCachePlugin
- EugenGanshorn/GuzzleBundleRetryPlugin
Events
This bundle dispatches Symfony events right before a client makes a call and right after a client has made a call. There are two types of events dispatched every time; a generic event, that is dispatched regardless of which client is doing the request, and a client specific event, that is dispatched only to listeners specifically subscribed to events from a specific client. These events can be used to intercept requests to a remote system as well as responses from a remote system. In case a generic event listener and a client specific event listener both change a request/response, the changes from the client specific listener override those of the generic listener in case of a collision (both setting the same header for example).
Listening To Events
In order to listen to these events you should create a listener and register that listener in the Symfony services configuration as usual:
For more information, read the docs on intercepting requests and responses.
Features
Symfony Debug Toolbar / Profiler
Logging
All requests are logged to Symfony's default logger (@logger
service) with the following (default) format:
Example:
You can change the message format by overriding the eight_points_guzzle.symfony_log_formatter.pattern
parameter.
For all options please refer to Guzzle's MessageFormatter.
Suggestions
Create aliases for clients
In case your project uses manual wiring it is recommended to create aliases for the clients created with this bundle to get easier service names and also to make it easier to switch to other implementations in the future, might the need arise.
In case your project uses autowiring this suggestion does not apply.
Contributing
👍 If you would like to contribute to this bundle, please read CONTRIBUTING.md.
#8p-guzzlebundle.
🎉 Thanks to all contributors who participated in this project.
Learn more
- Autowiring Clients
- Configuration Reference
- Disable throwing exceptions on HTTP errors (4xx and 5xx responses)
- Environment variables integration
- How to create a single-file plugin
- How to redefine class used for clients
- Intercept request and response
License
This bundle is released under the MIT license.
All versions of guzzle-bundle with dependencies
guzzlehttp/guzzle Version ^6.5.8|^7.4.5
guzzlehttp/promises Version ^1.5.3|^2.0
guzzlehttp/psr7 Version ^1.9.1|^2.5
symfony/framework-bundle Version ~5.0|~6.0|~7.0
symfony/expression-language Version ~5.0|~6.0|~7.0
symfony/stopwatch Version ~5.0|~6.0|~7.0
psr/log Version ~1.0|~2.0|~3.0