How do you log all API calls using Guzzle 6

You can use any logger which implements PSR-3 interface with Guzzle 6 I used Monolog as logger and builtin middleware of Guzzle with MessageFormatter in below example. use GuzzleHttp\HandlerStack; use GuzzleHttp\Middleware; use GuzzleHttp\MessageFormatter; use Monolog\Logger; $stack = HandlerStack::create(); $stack->push( Middleware::log( new Logger(‘Logger’), new MessageFormatter(‘{req_body} – {res_body}’) ) ); $client = new \GuzzleHttp\Client( [ ‘base_uri’ => … Read more

Guzzle 6 progress of download

Though, its not mentioned within the documentation, you can use the “progress” request option. References to it can be found here. $options = [ ‘progress’ => function ($dl_total_size, $dl_size_so_far, $ul_total_size, $ul_size_so_far) { // do something. } ];

Upload file using Guzzle 6 to API endpoint

The way you are POSTing data is wrong, hence received data is malformed. Guzzle docs: The value of multipart is an array of associative arrays, each containing the following key value pairs: name: (string, required) the form field name contents:(StreamInterface/resource/string, required) The data to use in the form element. headers: (array) Optional associative array of … Read more