Skip to content

A Guzzle plugin that lets you debug everything in the Clockwork browser extension.

License

Notifications You must be signed in to change notification settings

kEERill/guzzle-clockwork

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Guzzle middleware for Clockwork logging

Build Status Latest Stable Version Code Quality Code Coverage Total Downloads License

Guzzle middleware for logging requests clockwork's timeline so you can view the timeline in your browser's developer tools.

Developer tools timeline

Usage

Composer install

composer require keerill/guzzle-clockwork
// 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');

Depending on your integration of Clockwork, make sure that you call $clockwork->requestProcessed(); before you output your page.

Laravel

If you are using Laravel, use the included service providers to add the subscriber to every Guzzle Client.

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

Be sure to create every client (type hint with GuzzleHttp\ClientInterface or GuzzleHttp\Client) via the IoC container.

Contributing

Feel free to make a pull request. Please try to be as PSR-2 compliant as possible. Fix Code Style quickly by running composer format. Give a good description of what is supposed to be added/changed/removed/fixed.

Testing

To test your code before pushing, run the unit test suite.

composer test

License

MIT

About

A Guzzle plugin that lets you debug everything in the Clockwork browser extension.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%