Voting

: eight minus eight?
(Example: nine)

The Note You're Voting On

jpatta at digitalgamesystems dot com
4 years ago
If you are looking the debug curl_exec, you may wish to log its details, and analyze the various time points during its execution.

before curl_exec:

<?php
// this will produce a curl log
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_STDERR, fopen('/your/writable/app/logdir/curl.log', 'a+')); // a+ to append...
?>

after curl_exec, but before curl_close:

<?php
// this will extract the timing information
extract(curl_getinfo($curl)); // create metrics variables from getinfo
$appconnect_time = curl_getinfo($curl, CURLINFO_APPCONNECT_TIME); // request this time explicitly
$downloadduration = number_format($total_time - $starttransfer_time, 9); // format, to get rid of scientific notation
$namelookup_time = number_format($namelookup_time, 9);
$metrics = "CURL...: $url Time...: $total_time DNS: $namelookup_time Connect: $connect_time SSL/SSH: $appconnect_time PreTransfer: $pretransfer_time StartTransfer: $starttransfer_time Download: $downloadduration";
error_log($metrics); // write to php-fpm default www-error.log, or append it to same log as above with file_put_contents(<filename>, $metrics, FILE_APPEND)
?>

Happy debugging

<< Back to user notes page

To Top