I’m sending JSON data to an external API using PHP cURL on Windows 10 with XAMPP (PHP 8.3).
- Small JSON payloads (1–2 KB) return a response normally within ~2 seconds.
 - As soon as the payload gets a few extra characters or items, the request takes a very long time and sometimes errors out.
 - The same request works instantly in Postman.
 
Here is a simplified version of my code:
$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => 'https://api.example.com/validate',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer ...'
    ],
]);
$response = curl_exec($curl);
curl_close($curl);
Things I’ve tried:
- Increasing post_max_size, memory_limit, max_execution_time in php.ini.
 - Disabling JSON_PRETTY_PRINT.
 - Testing with JSON payloads of different sizes.
 - Running the script via CLI (faster than through browser).
 
Environment:
- Windows 10
 - XAMPP (Apache + PHP 8.3)
 - cURL enabled
 - JSON payloads range from 1 KB to 100+ KB
 
Symptoms:
PHP cURL is much slower than Postman for slightly larger payloads.
With few more JSON values request may fail or hang even with less few items request complete in under 2 seconds
Questions:
- Why does PHP cURL become slow or fail with slightly larger JSON payloads in this environment?
 - How can I reliably send larger JSON payloads via cURL on XAMPP without long delays or errors?
 - Are there any Windows/XAMPP/PHP specific settings I need to adjust (DNS, SSL, buffer sizes, timeouts, etc.)?