Requests for PHP sends HTTP requests with a small array-based API. It wraps cURL or fsockopen so callers avoid low-level socket or cURL details.
Overview
Requests is an HTTP library for PHP positioned for straightforward use in application code. Its API is modeled after the Python Requests project. It depends only on PHP 5.6.20 or newer and ships under an ISC-style license.
The library supports HEAD, GET, POST, PUT, DELETE, and PATCH with headers, form fields, multipart files, and parameters expressed as arrays. Responses expose status, headers, and body through the same style of structures. Transport uses cURL when available and falls back to fsockopen while keeping a consistent interface.
Documented features include international domains and URLs, browser-style SSL verification, basic and digest authentication, automatic decompression, and connection timeouts. Install via Composer as rmccue/requests, clone with autoload registration, or use PSR-4 loaders. PHPDoc covers the API; prose guides walk through typical calls.
PSR-7 and PSR-18 post-date the core library, which does not ship native implementations; a separate community package adapts Requests as a PSR-18 client. WordPress maintains the project and discusses HTTP API work in its Slack core-http-api channel.
Key features
- GET POST PUT PATCH DELETE HEAD
- cURL and fsockopen transports
- SSL verification and auth hooks
- Multipart and form uploads
- Automatic response decompression
- Connection timeout support
- Composer and manual install paths
Use cases
- Calling REST APIs from PHP apps
- WordPress plugin HTTP integrations
- Replacing raw cURL in legacy PHP
- Fetching JSON with simple headers