1. Go to this page and download the library: Download sergey-bel/curl-printer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sergey-bel / curl-printer example snippets
$request = new RequestData(
HttpMethod::POST,
'https://someapi.com/user',
[
'Accept' => 'application/json',
],
'id=12345'
);
$printer = new CurlPrinter();
echo $printer->print($request);
// curl -X POST https://someapi.com/user -H 'Accept: application/json' -d 'id=12345'
// $psr7Request implements RequestInterface
$extractor = new PsrRequestExtractor();
$printer = new CurlPrinter();
$request = $extractor->extract($psr7Request)
$printer->print($request);
$logger = // some LoggerInterface
$stack = new HandlerStack();
$stack->push(new CurlPrinterMiddleware($logger));
$client = new Client(['handler' => $stack]);
$client->send(...);
$settings = (new FormatterSettings())
->setQuotes('"');
$request = new RequestData(
HttpMethod::POST,
'https://someapi.com/user',
[
'Accept' => 'application/json',
],
'id=12345'
);
$printer = (new CurlPrinter())->setSettings($settings);
echo $printer->print($request);
// curl -X POST https://someapi.com/user -H "Accept: application/json" -d "id=12345"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.