PHP code example of hannesvdvreken / guzzle-clockwork

1. Go to this page and download the library: Download hannesvdvreken/guzzle-clockwork 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/ */

    

hannesvdvreken / guzzle-clockwork example snippets


// First you need a Clockwork object
$clockwork = \Clockwork\Support\Vanilla\Clockwork::init();

// Create the Guzzle middleware
$middleware = new \GuzzleHttp\Profiling\Middleware(
    new \GuzzleHttp\Profiling\Clockwork\Profiler($clockwork->getClockwork()->timeline())
);

// Then you need to add it to the Guzzle HandlerStack
$stack = \GuzzleHttp\HandlerStack::create();

$stack->unshift($middleware);

$client = new \GuzzleHttp\Client(['handler' => $stack]);

$client->get('https://httpbin.org/status/418');

'providers' => [
    ...
    \Clockwork\Support\Laravel\ClockworkServiceProvider::class,
    \GuzzleHttp\Profiling\Clockwork\Support\Laravel\ServiceProvider::class,
],