hannesvdvreken / guzzle-profiler
A Guzzle middleware that profiles requests made by the client.
Fund package maintenance!
hannesvdvreken
Installs: 342 339
Dependents: 4
Suggesters: 0
Security: 0
Stars: 6
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.2
- guzzlehttp/guzzle: ^6.0|^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.2.20
- phpunit/phpunit: ^8.2.3
README
⚠️ This project is up for adoption. Get in touch if you're interested in actively maintaining 3 closely related packages.
Guzzle Middleware to log made HTTP requests to a timeline for debugging.
Adapter
A couple of adapters are available:
Usage
// First you need a HandlerStack $stack = GuzzleHttp\HandlerStack::create(); // Create a middleware by wrapping a profiler (eg: DebugBar's profiler): /** @var DebugBar\DebugBar $debugBar */ $timeline = $debugBar->getCollector('time'); $profiler = new GuzzleHttp\Profiling\DebugBar\Profiler($timeline); $middleware = new GuzzleHttp\Profiling\Middleware($profiler); // Add the Middleware to the stack of middlewares. $stack->unshift($middleware); // Then you need to add it to the Guzzle HandlerStack $stack = GuzzleHttp\HandlerStack::create(); $stack->unshift($middleware); // Create a Guzzle Client with the new HandlerStack: $client = new GuzzleHttp\Client(['handler' => $stack]);
And you are done! All requests will now be logged to whatever profiler you wrapped.
Contributing
Feel free to make a pull request. Please try to be as
PSR-2
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.
Testing
To test your code before pushing, run the unit test suite.
vendor/bin/phpunit