Download the PHP package drupflare/stream-http without Composer

On this page you can find all versions of the php package drupflare/stream-http. 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 stream-http

๐ŸŒ stream-http

An https:// stream wrapper for PHP builds that have no sockets

Packagist Build Coverage Prettier codecov

file_get_contents('https://...') works in a PHP-in-wasm runtime. The caller supplies the fetch; the package needs no sockets, no cURL, no OpenSSL transport and no framework.


๐Ÿ“‹ Table of Contents


๐Ÿ“ฅ Install


๐Ÿš€ Quick Start

Nothing else is needed. fopen(), fread(), fseek(), feof(), filesize(), file_exists() and stream_get_contents() all work from that point on, for both http:// and https://.


๐Ÿ”Œ Fetch Contract

One callable and two array shapes are the entire integration surface.

The request the wrapper builds:

Key Type Notes
url string verbatim, exactly as the caller wrote it
method string upper-cased; GET unless a stream context says otherwise
headers array name to value, from the context's header string or list
body string\|null the context's content, or null
redirect string follow or manual, from the context's follow_location

The reply it accepts:

Key Type Notes
ok bool anything other than true is a refusal
body string required when ok โ€” send '' for a bodiless response
status int optional; cast, and reported through responseMeta()
headers array optional; non-string values are dropped rather than cast
error string the named reason, when ok is not true

body is required, not defaulted to ''. A default would make a transport that omitted the field look like an empty 204.


๐Ÿฅ‡ Registering From the Host

A stream wrapper has to exist before any code that uses one runs. A service container is built too late for that, so a service provider or a module hook is the wrong place. In the project this was extracted from, registration happens from the JavaScript host, in worker/src/drupal/site-php.ts, around the HttpsStreamWrapper::register() call in the boot script, before Drupal's kernel exists.


๐Ÿšซ Out of Scope


๐Ÿงญ API

Member What it does
register(callable $fetch, ?array) sets the fetch and takes over the schemes; returns what it claimed
unregister(?array $schemes) restores PHP's own wrappers and forgets the fetch
setFetch(callable $fetch) sets the process-wide fetch without touching the registry
fetcher() the process-wide fetch, or null
lastError() the last named refusal, because a stream call only returns false
new HttpsStreamWrapper(?callable) an instance with its own fetch, which wins over the process-wide one
responseMeta() status and headers of the response this instance is serving
SCHEMES ['http', 'https'], the registrar's default

Why both a constructor and a static registrar. PHP constructs a registered wrapper with no arguments (stream_wrapper_register() takes the class name, not an instance), so a constructor-only design cannot work for the registered path. The static registrar is the production route; the constructor parameter is the escape hatch that makes the class drivable directly, which is how the suite exercises it without touching the wrapper registry at all.


๐Ÿ“‡ Reading Response Metadata

PHP populates $http_response_header only for its own http wrapper, and a userland wrapper cannot set it. What PHP does give you is the wrapper instance itself:

[!NOTE] This method is not called stream_metadata. That name belongs to the streamWrapper prototype, where PHP invokes it as stream_metadata(string $path, int $option, mixed $value) for touch(), chmod() and chown(). A 0-argument method under that name is an ArgumentCountError waiting for the first caller who touches an http:// path.


Every byte moves through the injected callable, so anything the wrapper cannot do refuses with a reason rather than returning a plausible empty result. A silent '' or false out of a stream function cannot be told apart from a real empty response.

PHP discards the warning text, so the reason is also readable afterwards:

Every one of these is refused by name and covered by the suite:

Situation Named reason contains
a non-read fopen() mode is read-only, so mode "w" is refused
no fetch was ever set ::register($fetch) first
the fetch threw the exception class and its message
the fetch returned a non-array where an array was expected
ok is false or absent the reply's error, or no reason given
ok with a missing or non-string body send an empty string for no body
a seek outside the body outside a N-byte body
a write through a read handle read-only

An explicitly empty body ('body' => '') opens normally, which is the control that keeps the six malformed-reply assertions from being vacuous.


๐Ÿงช Testing

The suite injects a recording fetch, so every request the wrapper builds is inspected and every malformed reply is scripted. No socket, no server, no wasm runtime.

A stream wrapper is resolved by method name at runtime: rename stream_read and PHP never calls it, with no error anywhere. The suite therefore drives the class through fopen(), fread() and fseek() wherever it can, rather than calling methods directly.


๐Ÿ”— Related Repositories

Repository What it is
drupflare/worker the consumer: Drupal 11 on Cloudflare Workers
drupflare/drupflare the Drupal module this was extracted from; wires Host::call
drupflare/cartridge the host side: running a blocking interpreter in a DO
drupflare/phasm builds the socketless PHP interpreter this wrapper serves

๐Ÿ“„ License

MIT (c) Gregory Mitchell 2026. See LICENSE.


All versions of stream-http with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
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 drupflare/stream-http contains the following files

Loading the files please wait ...