Files
php-curl-class/TROUBLESHOOTING.md
T
Konrad Abicht e89823a1cb TROUBLESHOOTING.md: use correct $curl properties (#878)
It seems the current values don't account for the `$curl` instance.
2024-08-17 02:14:48 +00:00

3.2 KiB

Troubleshooting

Debug using the diagnose method

$curl = new Curl();
$curl->get('https://www.example.com/');
$curl->diagnose(); // ← HERE

Debug the entire curl instance

$curl = new Curl();
$curl->get('https://www.example.com/');
var_dump($curl); // ← HERE

Ensure you have the latest version of the library installed

$ cd php-curl-class/
$ composer update
$ composer info

Compare your version with latest release which is also listed on the releases page.

Ensure php is using the latest version of curl

$ php -r 'var_dump(curl_version());'

Compare your version of curl with latest release which is also listed on curl's releases page.

Turn on error reporting

error_reporting(E_ALL);

Print some information that may hint at the cause of failure

error_reporting(E_ALL);
$curl = new Curl();
$curl->get('https://www.example.com/');
echo 'error: ' . $curl->error . "\n";
echo 'errorCode: ' . $curl->errorCode . "\n";
echo 'errorMessage: ' . $curl->errorMessage . "\n";
echo 'curlError: ' . $curl->error . "\n";
echo 'curlErrorCode: ' . $curl->errorCode . "\n";
echo 'curlErrorMessage: ' . $curl->errorMessage . "\n";
echo 'httpError: ' . $curl->httpError . "\n";
echo 'httpStatusCode: ' . $curl->httpStatusCode . "\n";
echo 'httpErrorMessage: ' . $curl->httpErrorMessage . "\n";
echo 'requestHeaders:' . "\n";
var_dump($curl->requestHeaders);
echo 'responseHeaders:' . "\n";
var_dump($curl->responseHeaders);

Turn on verbose mode

error_reporting(E_ALL);
$curl = new Curl();
$curl->verbose();
$curl->get('https://www.example.com/');
var_dump($curl);

Compare request with and without the library

error_reporting(E_ALL);
$curl = new Curl();
$curl->get('https://www.example.com/');
var_dump($curl);
error_reporting(E_ALL);
$ch = curl_init();
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_HTTPGET, true);
$raw_response = curl_exec($ch);
$curl_error_code = curl_errno($ch);
$curl_error_message = curl_error($ch);
$http_status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$request_headers = curl_getinfo($ch, CURLINFO_HEADER_OUT);
var_dump($http_status_code);
var_dump($curl_error_code);
var_dump($curl_error_message);
var_dump($request_headers);
var_dump($raw_response);

Ensure you have the latest version of composer installed

$ composer self-update
$ composer --version

Compare your version of composer with latest release which is also listed on composer's releases page.