PHP code example of playbloom / guzzle-bundle

1. Go to this page and download the library: Download playbloom/guzzle-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

playbloom / guzzle-bundle example snippets



    // in %your_project%/app/AppKernel.php
    $bundles[] = new Playbloom\Bundle\GuzzleBundle\PlaybloomGuzzleBundle();

use GuzzleHttp\Client;

$client = new Client(['base_url' => 'https://api.example.com']);

$logger = $container->get('playbloom_guzzle.client.plugin.subscriber.logger');
$client->getEmitter()->attach($logger);

$profiler = $container->get('playbloom_guzzle.client.plugin.subscriber.profiler');
$client->getEmitter()->attach($profiler);

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;

$stack = HandlerStack::create();

$logger = $container->get('playbloom_guzzle.client.plugin.middleware.logger');
$stack->push($logger);

$profiler = $container->get('playbloom_guzzle.client.plugin.middleware.profiler');
$stack->push($profiler);

$client = new Client([
    'base_uri' => 'https://api.example.com',
    'handler' => $stack
]);