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.
Pros:
GET, POST, PUT, DELETE, PATCH, HEAD) and advanced features like sessions, authentication, and SSL verification—directly addressing Laravel’s need for robust HTTP client capabilities.cURL (preferred) with fsockopen fallback, ensuring reliability across shared hosting environments where cURL might not be available.Cons:
Guzzle or Symfony HTTP Client). Requires a wrapper (e.g., art4/requests-psr18-adapter) for modern Laravel apps.composer.json constraints.Laravel Horizon).Http client (which uses Guzzle under the hood) for lightweight use cases, reducing bundle size and dependency complexity.Illuminate\Support\Facades\Http facade via a custom macro or wrapper class, enabling a unified HTTP abstraction layer.// In AppServiceProvider::boot()
Http::macro('requests', function ($method, $url, $data = [], $options = []) {
return \WpOrg\Requests\Requests::request($method, $url, $data, $options);
});
art4/requests-psr18-adapter (adds ~100 lines of boilerplate code).symfony/http-client)?cURL is unavailable (requiring fsockopen fallback)?WpOrg\Requests\Requests in a Laravel facade (e.g., Http::requests()) to maintain consistency with existing Http client usage.$this->app->singleton('requests', function ($app) {
return new \WpOrg\Requests\Requests();
});
HttpClient to delegate to Requests for specific endpoints:
Http::macro('legacy', function ($url, $options = []) {
return \WpOrg\Requests\Requests::get($url, [], $options);
});
art4/requests-psr18-adapter to bridge Requests with Laravel’s PSR-compliant HTTP stack:
composer require art4/requests-psr18-adapter
$client = new \Art4\RequestsPsr18Adapter\RequestsClient();
$response = $client->sendRequest(new \Psr\Http\Message\RequestInterface(...));
Requests.App\Services\RequestsClient) to encapsulate WpOrg\Requests\Requests and add Laravel-specific features (e.g., logging, retries).class RequestsClient {
public function get($url, array $headers = [], array $options = []) {
$response = \WpOrg\Requests\Requests::get($url, $headers, $options);
return new RequestsResponse($response);
}
}
Http::fake()).Requests responses in integration tests to validate behavior.composer.json constraints:
"require": {
"rmccue/requests": "^2.0",
"php": "^8.0"
}
guzzlehttp/guzzle, symfony/http-client).rmccue/requests and guzzlehttp/guzzle in the same project to prevent ambiguity.fsockopen fallback behavior.Requests.Requests-specific edge cases (e.g., SSL errors).Requests for new features.libcurl).Requests lacks native Laravel integration (e.g., Http client plugins).Requests::test() with Capability::SSL to verify transport availability.How can I help you explore Laravel packages today?