The other day the
namshi/cuzzle PHP pacakge came in really handy.
This library let’s you dump a Guzzle request to a cURL command for debug and log purposes
This way I could test some things on the CLI, and easily share these tests with all my colleagues, including those without PHP installed.
use Namshi\Cuzzle\Formatter\CurlFormatter; use GuzzleHttp\Message\Request; $request = new Request('GET', 'example.local'); $options = ; echo (new CurlFormatter())->format($request, $options); // ~> curl example.local -X GET -A 'GuzzleHttp/6.4.1 curl/7.71.1 PHP/7.4.9'
Also comes with a Monolog formatter to easily log the resulting curl commands in your log files. Do keep in mind that you might be leaking sensitive information (passwords/tokens) that way …
Installation per Composer:
composer require namshi/cuzzle