Skip to content

Dump Artax requests and responses for logging and debugging

License

Notifications You must be signed in to change notification settings

OWOX/ArtaxDumper

Repository files navigation

ArtaxDumper - dump Artax requests and responses for logging and debugging

Build Status Coverage Status License: MIT PHPStan

Install it with:

composer require owox/artax-dumper

Only curl request dumper hugely inspired by cuzzle available for now. It can be used for copy/paste requests logging:

\Amp\Loop::run(static function () {
    $curlRequestDumper = new \ArtaxDumper\Request\CurlRequestDumper();
    
    // GET Request
    $request = new \Amp\Artax\Request('https://httpbin.org/get');
    
    $curl = yield $curlRequestDumper->dump($request); // => curl "https://httpbin.org/get"
    
    // POST Request
    $request = (new \Amp\Artax\Request($uri = 'https://httpbin.org/post', 'POST'))
        ->withBody($body = 'foo=bar');
    
    $curl = yield $curlRequestDumper->dump($request); // => curl -d "foo=bar" "https://httpbin.org/post"
});