Download the PHP package rasuvaeff/context-http without Composer

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

rasuvaeff/context-http

Latest Stable Version Total Downloads Build Static analysis Psalm level PHP

PSR-15 and PSR-18 adapters for rasuvaeff/context: a request-scoped deadline, cancellation and correlation id, propagated across service calls.

Using an AI coding assistant? llms.txt contains a compact API reference you can share with the model.

Requirements

Installation

Limitations

These adapters bound how long a request waits; they do not abort work already running. See the transport matrix in rasuvaeff/context.

Usage

ContextMiddleware (PSR-15)

Creates one context per request, publishes it as request attributes and cancels it in finally:

Argument Default Effect
timeout 30.0 Request budget in seconds, or a callable deriving it from the request
correlationHeader X-Correlation-ID Incoming correlation header
contextAttribute / controllerAttribute / correlationAttribute class names Request attribute names
timeSource HrTimeSource Monotonic clock (tests)
deadlineHeader null Incoming budget in whole milliseconds (1–999999999); it only shortens the timeout — a longer or malformed value is ignored
correlationIdGenerator CorrelationId::generate(...) Used when the header is missing or invalid
responseFactory null When set, ContextExpiredException → expiredStatus, ContextCancelledException → cancelledStatus; otherwise they propagate
expiredStatus / cancelledStatus 504 / 499 Mapped status codes
wireCodec null A rasuvaeff/context WireCodec: allow-listed request values are read from the baggage header
baggageHeader baggage Header carrying the values (W3C Baggage)

Every request gets a CorrelationId: the incoming header when valid, otherwise a freshly generated one. The value is also stored in the context ($context->value(CorrelationId::class)), so outbound clients can forward it.

PreflightClient (PSR-18)

Checks assertActive() before starting a request and after receiving the response. PSR-18 has no transport options, so it cannot impose a timeout on a blocking client call — configure the client's own timeout, or use ContextClient with Guzzle. An explicit correlation header on the request wins over the context's.

ContextClient (Guzzle)

Propagating one deadline across services

Use the same header name on both sides. The receiving middleware never trusts a budget longer than its own timeout.

Request values across services (baggage)

The budget crosses services on its own header; request-scoped values (tenant, locale, experiment flags) travel in the standard W3C baggage header through a rasuvaeff/context WireCodec: only classes implementing WireValue, under aliases you allow.

Side Behaviour
Incoming Members with an allow-listed alias are decoded through WireValue::fromWire(); an invalid value, an unknown key or a malformed member is dropped, never thrown; a header over 8192 bytes is ignored. The values never touch the budget
Outgoing The context's values are appended to baggage; members already present (e.g. from the OpenTelemetry SDK) are kept verbatim and a key already present is never overridden. Values are percent-encoded; an entry that would exceed 8192 bytes or 180 members is dropped

Trace ids are not carried here: that is traceparent, owned by OpenTelemetry.

Queue consumers

Keep the controller with the message owner and derive a fresh context from the message TTR; call assertActive() before each step and NACK or dead-letter on ContextExpiredException. The package does not depend on a queue implementation.

Public API

Class Description
ContextMiddleware PSR-15: request context, controller and correlation id attributes; budget header; exception mapping
PreflightClient PSR-18 decorator: pre/post context checks, outbound budget and correlation headers
ContextClient Guzzle-compatible adapter: budget → timeouts, PSR-18 error semantics, expiry mapping
CorrelationId Validated correlation id (isValid(), generate())

Security

Examples

See examples/ for runnable scripts.

Script Shows Needs server?
basic.php Middleware reading an upstream budget and correlation id, PreflightClient forwarding both downstream, mapped responses no

Development

No PHP/Composer on the host — run in Docker via the composer:2 image:

Or with Make: make build, make cs-fix, make test, make test-coverage, make mutation, make release-check.

License

BSD-3-Clause


All versions of context-http with dependencies

PHP Build Version
Package Version
Requires php Version 8.3 - 8.5
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
rasuvaeff/context Version ^0.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 rasuvaeff/context-http contains the following files

Loading the files please wait ...