cURL to PHP

Transform your cURL requests into production-ready PHP scripts using the standard cURL extension.

<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.example.com/v1/users');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

$headers = [
    'Authorization: Bearer YOUR_TOKEN',
    'Content-Type: application/json',
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_POSTFIELDS, '{"name": "John Doe"}');

$response = curl_exec($ch);
curl_close($ch);

echo $response;

Native cURL

The generator uses PHP's native `curl_init` and `curl_setopt` functions, ensuring compatibility with most PHP environments without external dependencies.

Header Parsing

Automatically extracts all `-H` headers from your cURL command and formats them into a clean PHP array for `CURLOPT_HTTPHEADER`.