cURL converter · PHP

cURL to PHP

Paste a curl command and get PHP that runs today. Use the built-in curl_* extension for zero dependencies, or Guzzle for PSR-7 semantics.

InputcURL command
1 secret
MethodPOST·Headers2·Body46 B· Chars 187
OutputPHP · curl(ext-curl)
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.example.com/v1/messages");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer sk_test_123",
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"to\":\"+15551234567\",\"body\":\"Hello from curl\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Inspect

Top guides for PHP

All guides →

Common questions

ext-curl or Guzzle?
ext-curl for scripts and legacy hosting — it's always available. Guzzle for real applications: middleware, promises, PSR-7.
How are file uploads emitted?
ext-curl uses CURLFile with an optional content type. Guzzle uses the multipart option array with fopen streams.
Basic auth?
ext-curl gets CURLOPT_USERPWD; Guzzle gets the 'auth' array with [user, password].
Is my curl sent anywhere?
No. Nothing leaves your browser.

Also convert cURL to

All guides →

Same parser, same idiomatic output — swap the target language whenever your stack changes. Every hub carries its own reference guides for methods, payloads, and auth.