Developed with love by KnpLabs Hire us for your project!
34

guzzle6-bundle

by e-moe

Integrates Guzzle 6 into your Symfony application

Symfony Guzzle6Bundle

Latest Stable Version
Total Downloads
Latest Unstable Version
License

Build Status
Coverage Status
SensioLabsInsight

This bundle integrates Guzzle 6.x into Symfony. Guzzle is a PHP framework for building RESTful web service clients.

Requirements

  • PHP 5.6 or above
  • Symfony 2.7 or above (including Symfony 3.x, 4.x)

Installation

To install this bundle, run the command below and you will get the latest version by Packagist.

composer require e-moe/guzzle6-bundle

To use the newest (maybe unstable) version please add following into your composer.json:

{
    "require": {
        "e-moe/guzzle6-bundle": "dev-master"
    }
}

Usage

Load bundle in AppKernel.php (should be done automatically if you are using Symfony Flex):
php
new Emoe\GuzzleBundle\EmoeGuzzleBundle(),

Configuration in config.yml (optional):
yaml
emoe_guzzle:
log:
enabled: true # Logging requests to Monolog
format: 'Guzzle: [{ts}] "{method} {uri} HTTP/{version}" {code}' # Optional log format customization

see more about log format syntax.

Using Guzzle in controllers:
php
$client = $this->get('guzzle.client');
$response = $client->get('http://example.com');

Using Guzzle in your own services:
yaml
application.my_service:
class: App\Service\MyService
arguments:
- "@guzzle.client"

or you can just use autowire feature with GuzzleHttp\ClientInterface type hint.

Features

Symfony Debug Profiler

Symfony Debug Timeline

Symfony Debug Toolbar

Symfony Debug Logs (Monolog Integration)

Suggestions

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.
yaml
services:
http.client:
alias: guzzle.client

Creating multiple clients:
If you want to have different Guzzle clients in your application all you need is to define them in services file and
add "guzzle.client" tag to turn on Symfony integration (Debug toolbar, logs, so on..).
``` yaml
services:
guzzle.client_one:
class: GuzzleHttp\Client
tags:
- { name: guzzle.client }

guzzle.client_two:
    class: GuzzleHttp\Client
    tags:
        - { name: guzzle.client }


## Authors
 - Nikolay Labinskiy aka e-moe

Inspired by Chris Wilkinson's and Florian Preusner's GuzzleBundles ([1][misd-guzzle], [2][8p]).

See also the list of [contributors][contributors] who participated in this project.

## License

This bundle is released under the [MIT license](LICENSE)








Copyright (c) 2015-2018 Nikolay Labinskiy aka e-moe

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • ConfigTreeBuilder update, php7.4
    By Nikolay Labinskiy, 4 months ago
  • Add php 7.3 (#31)
    By e-moe, 1 year ago
  • vendors update, new coding standard (#28)
    By web-flow, 1 year ago
  • Update LICENSE
    By web-flow, 1 year ago
  • Added BC for deprecated constructing a TreeBuilder without passing root node information
    By e-moe, 1 year ago
  • composer github oauth
    By web-flow, 1 year ago
  • Remove confusion line from documentation
    By web-flow, 1 year ago
  • Log format syntax note (#22)
    By web-flow, 1 year ago
  • Added service usage examples in README.md
    By web-flow, 2 years ago
  • Fix license URL
    By web-flow, 2 years ago
  • fix test namespace declarations (#21)
    By web-flow, 2 years ago
  • #19 new alias for "guzzle.client" (#20)
    By e-moe, 2 years ago
  • mv LICENSE file
    By Nikolay Labinskiy, 2 years ago
  • Update README.md
    By web-flow, 2 years ago
  • testReset in GuzzleDataCollector
    By Nikolay Labinskiy, 2 years ago
  • Symfony4 fixes
    By Nikolay Labinskiy, 2 years ago
  • update composer.lock
    By e-moe, 2 years ago
  • php7 checks in CI
    By web-flow, 2 years ago
  • Requirements update
    By web-flow, 2 years ago
  • sf >= 3.4 compatibility: make guzzle.client public
    By web-flow, 2 years ago
  • Fix typo in template methods list (#15)
    By e-moe, 2 years ago
  • Replaced the icon with a SVG to not trigger CSP warnings. (#13)
    By e-moe, 2 years ago
  • Fix HHVM builds (switch to Ubuntu Trusty)
    By web-flow, 2 years ago
  • dates update
    By web-flow, 3 years ago
  • URL fix
    By web-flow, 3 years ago
  • Update services and config usage syntax
    By web-flow, 3 years ago
  • Remove the *.class parameters (#10)
    By web-flow, 3 years ago
  • Fixed error on profiler page for legacy Symfony versions <=2.7 (#9)
    By e-moe, 3 years ago
  • Merge pull request #8 from Brandon0/master
    By web-flow, 3 years ago
  • Attach handler to Monolog middleware just once, not for each client definition.
    By Brandon0, 3 years ago