PHPackages                             mapudo/guzzle-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. mapudo/guzzle-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

mapudo/guzzle-bundle
====================

The Mapudo GuzzleBundle allows integrating Guzzle into Symfony projects

v2.3.0(7y ago)1423.8k↓35.7%4[4 PRs](https://github.com/Mapudo/guzzle-bundle/pulls)MITPHPPHP ^7.0CI failing

Since Mar 3Pushed 6y ago4 watchersCompare

[ Source](https://github.com/Mapudo/guzzle-bundle)[ Packagist](https://packagist.org/packages/mapudo/guzzle-bundle)[ RSS](/packages/mapudo-guzzle-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (11)Versions (16)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fefde6c94352f489ed1bf7140fd7832e330cca3d7267fb84357b22d5bcb84e3b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617075646f2f67757a7a6c652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mapudo/guzzle-bundle)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3b2b3db65a1effa1f29bfc15ca0a410a37d6e8a456b4caad79f377569f7e1909/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d617075646f2f67757a7a6c652d62756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/mapudo/guzzle-bundle)[![Total Downloads](https://camo.githubusercontent.com/05713c70f0fdce7366d0c34fcda5ee010f97b3e84d14a33cebccfd374d398ef4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617075646f2f67757a7a6c652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mapudo/guzzle-bundle)

**[Requirements](#requirements)** | **[Install](#install)** | **[Usage](#usage)** | **[Contributing](#contributing)** | **[Security](#security)** | **[License](#license)** | **[About](#about)**

GuzzleBundle
============

[](#guzzlebundle)

The Mapudo GuzzleBundle allows integrating [Guzzle](https://github.com/guzzle/guzzle) into Symfony projects.

The main features of this bundle are:

- Easy addition of custom middleware and event listeners
- Close to 100% test coverage
- Written from the ground up for PHP 7
- Built-in middleware for
    - Logging via Monolog on a separate `guzzle` channel
    - Request debugging via Symfony Profiler (styled with Bootstrap) and DebugBar
    - Event dispatching via Symfony Event Framework

Why [yet another Guzzle Bundle](https://xkcd.com/927/)? We simply weren't happy with the code quality and middleware integration of existing bundles and our issues were not addressed by their maintainers.

Requirements
------------

[](#requirements)

- PHP 7.0 and newer
- Symfony ~2.8|~3.0|~4.0

Install
-------

[](#install)

Via Composer

```
$ composer require mapudo/guzzle-bundle
```

Usage
-----

[](#usage)

### Activating the bundle

[](#activating-the-bundle)

Register the bundle in your `AppKernel.php`.

```
// app/AppKernel.php
...
new Mapudo\Bundle\GuzzleBundle\GuzzleBundle(),
...
```

### Configuration

[](#configuration)

Configure the bundle via `app/config.yml`. You can define multiple clients and set basic options.

```
guzzle:
    clients:
        test_client:
            base_uri: 'https://example.com/path'
            headers:
                Accept: 'application/json'
                Accept-Language: 'de'
            request_options:
                allow_redirects: true
                cert:
                    - '/path/to/cert.pem'
                    - 'password'
        another_client:
            base_uri: 'https://another.example.com/root/child'
            headers:
                X-Auth: 'token'
```

All `request_options` documented in the [Guzzle documentation](http://docs.guzzlephp.org/en/latest/request-options.html)can be configured for clients, except for the following which can only be set on individual requests:

- `body`
- `cookies`
- `debug`
- `form_params`
- `json`
- `multipart`
- `on_headers`
- `on_stats`
- `progress`
- `sink`

Clients defined in the configuration are then registered by the bundle's CompilerPass and you can afterwards access them from the container by name. For the above cases, we would have two clients which we can access with `guzzle.client.test_client` and `guzzle.client.another_client`.

### Making requests

[](#making-requests)

Making requests is easy and essentially the same as using Guzzle directly. As described above, you can also set `request_options` here that are not available to configure via the config.

```
