rmccue/requests
Requests is a human-friendly PHP HTTP client for sending GET/POST/PUT/DELETE/PATCH/HEAD requests with headers, auth, files, and parameters. Supports cURL or fsockopen, SSL verification, decompression, and IDN URLs with a consistent API.
POST/PUT requests (e.g., Stripe, GitHub webhooks) with built-in auth and retries.file_get_contents() or curl_exec() calls with a maintainable, feature-rich alternative.Session objects.Adopt if:
art4/requests-psr18-adapter if needed).php-curl-multi.Look elsewhere if:
"Requests for PHP is a low-risk, high-reward HTTP library that lets us standardize API interactions across our Laravel services. It’s dependency-free, battle-tested (used by WordPress), and secure by default—reducing vulnerabilities from ad-hoc cURL calls. By adopting this, we cut development time for integrations (e.g., payment processors, SaaS tools) by 30% while improving reliability. The trade-off? Minimal learning curve and no vendor lock-in."
Key Metrics to Track:
*"Requests gives us a Python-like simplicity for HTTP in PHP, abstracting cURL/fsockopen into a clean API. Here’s why it’s a win:
\WpOrg\Requests\Auth in 10 lines.Migration Path:
curl_exec() or file_get_contents() calls with Requests::get().Session objects for multi-request workflows (e.g., GitHub API pagination).art4/requests-psr18-adapter if PSR-18 is ever needed.Example Win:
// Before (spaghetti cURL):
$ch = curl_init('https://api.example.com/data');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer token']);
$response = curl_exec($ch);
// After (clean):
$response = Requests::get('https://api.example.com/data', [], [
'auth' => ['token']
]);
Risks:
How can I help you explore Laravel packages today?