Convert curl to PHP

Instantly convert your curl commands to PHP code using the cURL extension library. Free, fast, and no signup required.

Examples:
Type or paste a curl command and click 'Convert' to see the code.
Target language:

Enter a curl command and click Convert to see the PHP code

About PHP HTTP Requests

PHP's cURL extension provides bindings to the libcurl library, enabling PHP applications to make HTTP requests to external servers. It's one of the most widely used methods for API integration in PHP applications, offering fine-grained control over request parameters and supporting all HTTP features.

Key Features

  • Built-in PHP extension (usually pre-installed)
  • Direct mapping to curl command-line options
  • Support for all HTTP methods and headers
  • Cookie handling and session management
  • SSL/TLS certificate verification
  • Proxy support and authentication
  • Multi-handle for concurrent requests

View official cURL extension documentation

Frequently Asked Questions

How do I convert a curl command to PHP?

Paste your curl command in the input box and click "Convert". The tool generates PHP code using the cURL extension with proper curl_setopt_array() configuration.

Do I need to install anything for PHP cURL?

The cURL extension is usually pre-installed with PHP. You can check by running php -m | grep curl. If not installed, you can enable it in your php.ini file.

How do I handle JSON responses in PHP?

Use json_decode($response, true) to convert the JSON response string to a PHP associative array. The second parameter true returns an array instead of an object.

Can I use Guzzle instead of cURL?

Guzzle is a popular PHP HTTP client that provides a higher-level API. While this tool generates native cURL code, Guzzle internally uses cURL and offers additional features like middleware.

How do I handle errors in PHP cURL?

The generated code includes curl_error() to capture error messages. Always check if curl_exec() returns false to detect errors, and use curl_errno() for error codes.

Convert curl to Other Languages