Guzzle’s cURL Option Keys Are PHP Constants
Fix a curl_setopt_array option-key warning by using integer CURLOPT constants in Guzzle’s low-level curl option array.
In a Guzzle 7 request using the cURL handler, the low-level curl option array uses PHP’s integer CURLOPT constants as keys:
$options = [
'curl' => [
CURLOPT_PROXY => 'proxy.example',
CURLOPT_PROXYPORT => 8080,
],
];
Keep the outer Guzzle key 'curl' quoted. Do not quote CURLOPT_PROXY or CURLOPT_PROXYPORT. Writing 'CURLOPT_PROXY' creates an ordinary string containing that name; PHP does not turn it into the constant’s numeric value.
This distinction explains the curl_setopt_array warning about keys needing CURLOPT constants or equivalent integers. Check the array shape before changing the proxy address or account: that warning is about configuring the handle, not evidence that the remote proxy refused a connection.
When no low-level cURL behavior is needed, Guzzle’s normal request option is simpler:
$options = [
'proxy' => 'http://proxy.example:8080',
];
Choose the intended interface and keep its key types consistent. Once that shape is valid, an HTTP entry from the HTTP proxy list can supply the endpoint for a permitted public-URL request without a proxy account. The low-level curl array requires the cURL handler; a different handler does not become cURL merely because that array is present.