From 992783cd430ae2abcbd432677dda3280ea2527bf Mon Sep 17 00:00:00 2001 From: Marco Polichetti Date: Sun, 29 May 2016 01:53:30 +0200 Subject: [PATCH] Improve README [ci skip] --- README.md | 95 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 011e994..38b5ac1 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,37 @@ # GremoBuzzBundle -[![Build status](https://img.shields.io/travis/gremo/GremoBuzzBundle.svg?style=flat-square)](https://travis-ci.org/gremo/GremoBuzzBundle) [![GitHub issues](https://img.shields.io/github/issues/gremo/GremoBuzzBundle.svg?style=flat-square)](https://github.com/gremo/GremoBuzzBundle/issues) [![Latest stable](https://img.shields.io/packagist/v/gremo/buzz-bundle.svg?style=flat-square)](https://packagist.org/packages/gremo/buzz-bundle) [![Downloads total](https://img.shields.io/packagist/dt/gremo/buzz-bundle.svg?style=flat-square)](https://packagist.org/packages/gremo/buzz-bundle) +[![Latest stable](https://img.shields.io/packagist/v/gremo/buzz-bundle.svg?style=flat-square)](https://packagist.org/packages/gremo/buzz-bundle) [![Downloads total](https://img.shields.io/packagist/dt/gremo/buzz-bundle.svg?style=flat-square)](https://packagist.org/packages/gremo/buzz-bundle) [![GitHub issues](https://img.shields.io/github/issues/gremo/GremoBuzzBundle.svg?style=flat-square)](https://github.com/gremo/GremoBuzzBundle/issues) -Symfony 2 Bundle for using the lightweight Buzz HTTP client. - -- [Installation](#installation) -- [Configuration](#configuration) -- [Usage](#usage) -- [Adding listeners](#adding-listeners) +Symfony Bundle for using the lightweight Buzz HTTP client. ## Installation +Add the bundle in your `composer.json` file: + +```js +{ + "require": { + "gremo/buzz-bundle": "~1.0" + } +} +``` + +Then run `composer update` and register the bundle with your kernel in `app/appKernel.php`: + +```php +registerNamespaces(array( // ... 'Buzz' => __DIR__.'/../vendor/buzz/lib', @@ -32,19 +56,12 @@ $loader->registerNamespaces(array( )); ``` -If you are using [Composer](http://getcomposer.org/) and Symfony >= 2.1.*, add the following to your `composer.json` file: - -```javascript -{ - "require": { - "gremo/buzz-bundle": "*" - } -} -``` - Finally register the bundle with your kernel in `app/appKernel.php`: ```php +get('gremo_buzz'); Refer to [Kris Wallsmith Buzz library](https://github.com/kriswallsmith/Buzz) for sending HTTP requests. -## Adding listeners -You can register a listener creating a service that implements `Buzz\Listener\ListenerInterface` and tagging it as `gremo_buzz.listener` (optionally defining a `priority` attribute). - -Higher priority means that the corresponding listener is executed first. Same priority would lead to unexpected behaviours, as well as not numerical ones. +## Dependency Injection Tags +You can register a listener creating a service that implements `Buzz\Listener\ListenerInterface` and tagging it as `gremo_buzz.listener` (optionally defining a `priority` attribute). Higher priority means that the corresponding listener is executed first. -An example listener that logs outgoing requests: +Example listener that logs outgoing requests: ```php +logger = $logger; } + /** + * {@inheritdoc} + */ public function preSend(RequestInterface $request) { $this->startTime = microtime(true); } + /** + * {@inheritdoc} + */ public function postSend(RequestInterface $request, MessageInterface $response) { - $seconds = microtime(true) - $this->startTime; - - $logger->info(sprintf( + $this->logger->info(sprintf( 'Sent "%s %s%s" in %dms', $request->getMethod(), $request->getHost(), $request->getResource(), - round($seconds * 1000) + round((microtime(true) - $this->startTime) * 1000) )); } }