carlescliment/curl
Lightweight PHP cURL wrapper by carlescliment. Simplifies making HTTP requests with an easy API for GET/POST and custom headers, options, and timeouts, returning response data and status info for quick integrations and scripting.
GET, POST, PUT, DELETE operations.curl_exec() calls with this wrapper is trivial (e.g., Curl::get('url')).HttpClient or Illuminate\Support\Facades\Http.curl options may complicate future migrations to PSR-18 compliant clients.HttpClient or Guzzle?
HttpClient: Native integration with Laravel’s service container and caching.curl: More control but verbose and error-prone.curl_exec() or Guzzle calls to identify migration scope.GET /users).// Before (raw curl)
$ch = curl_init('https://api.example.com/users');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
// After (wrapper)
$response = Curl::get('https://api.example.com/users');
Curl::post('https://api.example.com/users', [
'headers' => ['Content-Type' => 'application/json'],
'body' => json_encode(['name' => 'John'])
]);
HttpClient mocking or PHPUnit’s Mockery to stub responses.curl extensions.curl_exec() calls with the wrapper.curl version compatibility.curl calls).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Network timeout | Request hangs or crashes | Set timeout via Curl::setOption() |
| Invalid response (e.g., 500) | Unhandled exceptions | Parse response manually or add middleware |
| SSL certificate errors | Request fails silently | Configure CURLOPT_SSL_VERIFYPEER |
| Rate limiting | API throttling | Implement exponential backoff manually |
| Dependency conflicts | curl extension missing |
Ensure PHP curl extension is enabled |
curl).HttpClient.How can I help you explore Laravel packages today?