This bundle integrates Guzzle 5.x into Symfony. Guzzle is a PHP framework for building RESTful web service clients. It comes with a WSSE Auth Plugin that can be used optionally.
GuzzleBundle follows semantic versioning. Read more on semver.org.
- PHP 5.4 or above
- Guzzle PHP Framework (included by composer)
- WSSE Auth Plugin (included by composer)
To install this bundle, run the command below and you will get the latest version by Packagist.
composer require eightpoints/guzzle-bundle
To use the newest (maybe unstable) version please add following into your composer.json:
{
"require": {
"eightpoints/guzzle-bundle": "dev-master"
}
}
Load bundle in AppKernel.php:
new EightPoints\Bundle\GuzzleBundle\GuzzleBundle()
Configuration in config.yml:
guzzle:
base_url: "http://api.domain.tld"
# custom headers
headers:
Accept: "application/json"
# plugin settings
plugin:
wsse:
username: acme
password: pa55w0rd
All these settings are optional. If WSSE username is defined the WSSE plugin will be injected automatically.
Using services in controller:
$client = $this->get('guzzle.client');
$response = $client->get('/users');
Adding aliases: If you want to use different names for provided services you can use aliases. This is a good idea if you don't want have any dependency to guzzle in your service name.
services:
http.client:
alias: guzzle.client
- Florian Preusner (Twitter)
See also the list of contributors who participated in this project.
This bundle is released under the MIT license