Skip to content

ludofleury/BuzzBundle

Repository files navigation

Playbloom Buzz Bundle

Provide a basic logger and an advanced profiler for Buzz This work is a quick port of the Playbloom GuzzleBundle. It may be improved with some features from the GuzzleBundle, yet I do not provide support, feel free to fork & PR.

  • The basic logger use the default Symfony app logger, it's safe to use in your production environement.
  • The advanced profiler is for debug purposes and will display a dedicated report available in the toolbar and in the Symfony Web Profiler

Buzz Symfony web profiler panel

Buzz Symfony web profiler panel - request details

Buzz Symfony web profiler panel - response details

Installation

Add the composer requirements (will be soon on packagist)

{
    "require-dev": {
        "playbloom/buzz-bundle": "dev-master"
    },

    "repositories": [
        {
            "type": "git",
            "url": "git://github.com/ludofleury/BuzzBundle.git"
        }
    ]
}

Add the bundle to your Symfony app kernel

<?php
    // in %your_project%/app/AppKernel.php
    $bundles[] = new Playbloom\Bundle\BuzzBundle\PlaybloomBuzzBundle();
?>

To enable the advanced profiler & the toolbar/web profiler panel, add this line to your app/config/config_dev.yml

playbloom_buzz:
    web_profiler: true

Buzz client as a Symfony service

Buzz is a lightweight browser so the service declaration is straightforward. Just add the tag playbloom_buzz.browser and it will add the basic logger to your client(s). If the web_profiler is enabled in the current environement, it will also add the advanced profiler and display report on the Symfony toolbar/web profiler.

<service id="acme.browser" class="Buzz\Browser">
    <tag name="playbloom_buzz.browser" />
</service>

Add the logger/profiler manually to a Buzz browser

To register the logger or profiler listener manually for a browser, you can retrieve theses services from the Symfony container.

<?php

$browser = new \Buzz\Browser();

// basic logger service plugged & configured with the default Symfony app logger
$loggerListener = $container->get('playbloom_buzz.browser.listener.logger');
$browser->addListener($loggerListener);

// advanced profiler for developement and debug, requires web_profiler to be enabled
$profilerListener = $container->get('playbloom_buzz.browser.listener.profiler');
$client->addListener($profilerListener);

?>

Limitations

  • It doesn't handle the logging/profiling for a Buzz Client, you need to use a Buzz browser (buzz implementation limitation).
  • The Message (request/response) from Buzz are really simple and so the informations in the profiler.
  • If you need a rock-solid HTTP client, try Guzzle and... the Playbloom GuzzleBundle !

Licence

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

Credits

  • Swagger for the UI

About

Debug your API Calls with a Symfony web profiler for Buzz

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages