PHP code example of uwebpro / curl-printer
1. Go to this page and download the library: Download uwebpro/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/ */
uwebpro / curl-printer example snippets
use CurlPrinter\CurlPrinter;
use GuzzleHttp\Psr7\Request;
$request = new Request(
'POST',
'https://someapi.com/v2/user/create',
[
'Accept' => 'application/json',
],
'user_id=12345'
);
$printer = new CurlPrinter();
echo $printer->printRequest($request);
// curl -X POST https://someapi.com/v2/user/create -d 'user_id=12345' -H 'Accept: application/json'
$logger = // some LoggerInterface
$stack = // Guzzle handler stack
$stack->push(new CurlPrinterMiddleware($logger));
$client = new Client(['handler' => $stack]);
$client->post(...);