A Guzzle middleware that logs requests with Clockwork
Guzzle middleware for logging requests clockwork's timeline so you can view the timeline in your browser's developer tools.
// 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->getTimeline()) ); // Then you need to add it to the Guzzle HandlerStack $stack = GuzzleHttp\HandlerStack::create(); $stack->unshift($middleware);
Depending on your integration of Clockwork, make sure that you call
$clockwork->requestProcessed(); before you output your page.
If you are using Laravel, use the included service providers to add the subscriber to every Guzzle Client.
'providers' => [ ... 'Clockwork\Support\Laravel\ClockworkServiceProvider', 'GuzzleHttp\Profiling\Clockwork\Support\Laravel\ServiceProvider', ]
Be sure to create every client (type hint with
GuzzleHttp\Client) via the IoC container.
0.2.0 and up until
1.0.0 (exclusively) are all compatible with Guzzle v4 and v5. To develop for these versions of Guzzle, use the
If you want to continue to work with the old Guzzle v3 (
Guzzle\Http\Client instead of
then you might want to install the
0.1.* releases. Pull request with Guzzle v3 compatibility should be made against the
guzzle3 branch. Install the latest guzzle v3 compatible version with
Feel free to make a pull request. Please try to be as
compliant as possible. Fix Code Style quickly by running
vendor/bin/php-cs-fixer fix. Give a good description of what is supposed to be added/changed/removed/fixed.
To test your code before pushing, run the unit test suite.