A Guzzle plugin that listens to events and logs them with Clockwork
Guzzle Subscriber for logging to clockwork so you can view the requests timeline and logs in your browser's developer tools.
// First you need a Guzzle HTTP Client $client = new GuzzleHttp\Client; // Then you need a Clockwork object $clockwork = new Clockwork\Clockwork; // Create the Guzzle subscriber $subscriber = new GuzzleHttp\Subscriber\Log\ClockworkSubscriber($clockwork); // Add it as a subscriber $client->getEmitter()->attach($subscriber);
And you are done!
If you are using Laravel 4, use the included service providers to add the subscriber to every Guzzle Client.
'providers' => [ ... 'Clockwork\Support\Laravel\ClockworkServiceProvider', 'GuzzleHttp\Subscriber\Log\Support\Laravel\ServiceProvider', ]
Be sure to create every client via the auto-resolving application container:
$client = App::make('GuzzleHttp\Client');
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
0.2.0 and up are all compatible with Guzzle v4 and v5.
Feel free to make a pull request. Please try to be as PSR-2 compliant as possible.
To test your code before pushing, run the unit test suite.