简体   繁体   中英

Guzzle 5 Request as cURL String

is there a way to get the complete Guzzle request as a string like it would be resolved as a cURL request? (Like the "copy as cURL request" option in the dev tools from Chrome or Firefox).

I know there is a library called "Cuzzle" ( https://github.com/namshi/cuzzle ), but it needs Guzzle 4 and I'm using version 5.

Any tips or help are appreciated. Thanks in advance :)

Fabian


Usage (for version 1.2.1, or Guzzle 5, as in OP's original question):

use Namshi\Cuzzle\Formatter\CurlFormatter;
use GuzzleHttp\Message\Request;

$request = new Request('GET', 'example.local');

echo (new CurlFormatter())->format($request);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM