Download the PHP package n5s/http-cli without Composer
On this page you can find all versions of the php package n5s/http-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package http-cli
Short Description Serverless HTTP client - make requests to PHP scripts on the command line
License MIT
Informations about the package http-cli
HTTP CLI
Serverless HTTP client - make requests to PHP scripts on the CLI.
This library lets you make HTTP requests to PHP applications without running a web server. Instead of Apache or nginx, it executes your PHP scripts directly via the command line while emulating the full HTTP environment ($_GET, $_POST, $_SERVER, $_SESSION, headers, cookies, etc.).
Perfect for testing, CI pipelines, unreleased deployment or any scenario where spinning up a web server is overkill or not possible.
Installation
Usage
How It Works
When you make a request, the library:
- Spawns a PHP CLI process targeting your script
- Injects a bootstrap that populates
$_GET,$_POST,$_SERVER,$_COOKIE, and$_SESSION - Provides polyfills for specific HTTP context functions:
header(),headers_sent(),http_response_code(), etc. - Captures the output and headers, returning a
Responseobject
Your PHP scripts run exactly as they would under a web server, but without one.
Framework Adapters
Use your favorite HTTP client library - just swap in our handler.
Guzzle
Symfony HttpClient
WordPress Requests
Request Options
Build requests with a fluent API:
Response
Configuration
Globals Handler
By default, the child PHP process receives a clean set of superglobals built from the HTTP request only. If your application depends on environment variables from the parent process (e.g. APP_ENV, DATABASE_URL), you can use the built-in InheritEnvGlobalsHandler:
This merges the parent's $_SERVER and $_ENV into the child process. Request-specific variables take precedence over inherited ones.
You can also implement the GlobalsHandler interface to customize superglobals however you need:
Adapter Options Support
Guzzle
| Option | Supported |
|---|---|
timeout |
✅ |
headers |
✅ |
query |
✅ |
body |
✅ |
json |
✅ |
form_params |
✅ |
multipart |
✅ |
auth |
✅ |
cookies |
✅ |
allow_redirects |
✅ |
http_errors |
✅ |
decode_content |
✅ |
version |
✅ |
sink |
✅ |
on_headers |
✅ (callback) |
on_stats |
✅ (callback) |
connect_timeout |
❌ ignored |
verify |
❌ ignored |
cert |
❌ ignored |
proxy |
❌ ignored |
ssl_key |
❌ |
progress |
❌ |
debug |
❌ |
Symfony HttpClient
| Option | Supported |
|---|---|
timeout |
✅ |
headers |
✅ |
query |
✅ |
body |
✅ |
json |
✅ |
auth_basic |
✅ |
auth_bearer |
✅ |
max_redirects |
✅ |
verify_peer |
❌ ignored |
verify_host |
❌ ignored |
cafile |
❌ ignored |
proxy |
❌ ignored |
http_version |
❌ |
on_progress |
❌ |
resolve |
❌ |
local_cert |
❌ |
local_pk |
❌ |
ciphers |
❌ |
WordPress Requests
| Option | Supported |
|---|---|
timeout |
✅ |
useragent |
✅ |
redirects |
✅ |
follow_redirects |
✅ |
auth |
✅ |
cookies |
✅ |
connect_timeout |
❌ ignored |
proxy |
❌ ignored |
verify |
❌ ignored |
verifyname |
❌ ignored |
filename |
❌ |
hooks |
❌ |
max_bytes |
❌ |
Limitations
Running PHP scripts via CLI instead of a web server comes with inherent limitations:
Not Supported
| Feature | Reason |
|---|---|
| Persistent connections | Each request spawns a new PHP process |
| Keep-alive | No connection reuse between requests |
| HTTP/2, HTTP/3 | CLI execution doesn't use HTTP protocol |
| WebSockets | Requires persistent connection |
| Server-Sent Events | Requires streaming connection |
| Real SSL/TLS | No actual HTTPS handshake (URLs are parsed, not connected) |
| Output streaming | Response is captured after script completes |
fastcgi_finish_request() |
FPM-specific function |
| APCu user cache | Not shared between CLI processes |
| OPcache benefits | Each process starts fresh |
| Static files | Only executes PHP - images, fonts, CSS, JS won't be served |
Behavioral Differences
- Performance: Process spawning overhead, but no DNS resolution, TCP/SSL handshake, or network latency
$_SERVERvalues: Some values likeSERVER_SOFTWAREwill differ from Apache/nginx- File uploads: Multipart parts are written to temp files and populated in
$_FILES - Session handling: Works but uses an in-memory handler, not file-based persistence
php://input: Custom stream wrapper provides the request body
License
MIT
All versions of http-cli with dependencies
symfony/http-foundation Version ^7.3 || ^8.0
symfony/process Version ^7.3 || ^8.0