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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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:

  1. Spawns a PHP CLI process targeting your script
  2. Injects a bootstrap that populates $_GET, $_POST, $_SERVER, $_COOKIE, and $_SESSION
  3. Provides polyfills for specific HTTP context functions: header(), headers_sent(), http_response_code(), etc.
  4. Captures the output and headers, returning a Response object

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

License

MIT


All versions of http-cli with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
symfony/http-foundation Version ^7.3 || ^8.0
symfony/process Version ^7.3 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package n5s/http-cli contains the following files

Loading the files please wait ...