Download the PHP package abdulsalam/laravel-context-flow without Composer

On this page you can find all versions of the php package abdulsalam/laravel-context-flow. 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 laravel-context-flow

Laravel Context Flow

Distributed context propagation for Laravel applications, built on top of Laravel Context instead of replacing it.

The package preserves one logical workflow across HTTP requests, queued jobs, scheduled work and service-to-service HTTP calls without passing correlation or tenant metadata through dozens of constructors.

Design rules

  1. Illuminate\Support\Facades\Context is the source of truth.
  2. correlation_id identifies the complete workflow.
  3. execution_id identifies one execution boundary.
  4. causation_id points to the execution that caused the current one.
  5. origin remains the root boundary that started the workflow; boundary is the current execution boundary.
  6. request_id is local to one HTTP request and is never reused by downstream services.
  7. Network propagation is explicit and trust-aware. Application metadata is never sent just because it exists in Context.
  8. Context is metadata, not authorization. Never authorize a tenant, role or user from propagated context alone.
  9. The package does not generate or overwrite traceparent / tracestate. OpenTelemetry instrumentation remains the owner of distributed tracing.

Requirements

Laravel 13 itself requires PHP 8.3+.

Installation

Publish the configuration when you need custom keys or trust policies:

The package auto-registers its service provider through Laravel package discovery.

Zero-config behavior

With the default configuration the package automatically:

No HasContext job trait and no custom queue payload format are used.

Basic usage

Use Laravel Context normally:

Inside the job:

The package's own facade is intentionally small:

It does not provide put/get/forget wrappers because Laravel Context already does that.

Registering application context keys

Only registered application keys are eligible for package-managed network propagation:

Available targets:

process and message_bus are extension targets in the policy model; the built-in v1 runtime automatically integrates HTTP and Laravel queues.

Internal HTTP propagation

Declare internal destinations:

Then ordinary Laravel HTTP calls are enriched automatically:

Typical headers:

X-Causation-ID is the caller's current execution_id. The receiving service creates its own execution and request IDs.

External HTTP is default-deny

By default:

receives no Context Flow headers.

This is controlled by:

If you deliberately switch that policy away from deny, only keys explicitly targeting http.external become eligible. Do not put credentials, session material or PII in propagated context.

Signed internal context

A host allowlist controls what this service considers an internal destination. It does not prove that an inbound request really came from an internal service.

For inbound restricted baggage (tenant_id, actor_id, etc.), enable signing on all cooperating services:

Outgoing internal calls receive:

The signature covers the correlation ID, causation ID, canonical baggage and timestamp. Inbound requests are treated as internal only when the signature is valid and within the configured timestamp tolerance.

Important: a valid signature still does not turn context into an authorization source. Re-resolve the authenticated principal and tenant using your normal security model.

Public inbound correlation IDs

By default a syntactically safe public X-Correlation-ID is accepted so clients can correlate support requests. Disable that if you want only server-generated IDs:

Incoming request IDs are never trusted; the package always creates a new local request ID.

Authentication / tenancy enrichment

The capture middleware is prepended globally, intentionally before authentication. If actor or tenant values only become available after auth/tenancy middleware, create an enricher:

Register it:

Then place the middleware after authentication on the routes/groups that need it:

Queue propagation

Laravel already serializes Context into queued jobs. This package hooks into Laravel's native dehydration/hydration lifecycle instead of adding properties to jobs.

When dispatching:

The job starts as:

A retry receives another execution ID while retaining the correlation lineage.

Queue compatibility policy

Laravel and third-party packages may store their own values in Context. Removing every unknown key would silently break them. Therefore the default is:

Registered Context Flow keys still obey their configured targets and sensitive-looking keys are removed.

For a strict application in which you fully own every Context key:

Local-only values

Register a key with no propagation targets:

Do not confuse Laravel hidden context with non-propagating context. Hidden context means it is hidden from logging; Laravel may still serialize it for queues. Context Flow applies propagation policy independently.

Scoped suppression

Disable propagation for a specific operation:

Or restrict application keys for a scope:

The package uses Laravel Context's scoped hidden data for these flags, so it does not store request-specific mutable state in package singletons.

Scheduler and Artisan

Artisan commands receive a root context when none exists.

Scheduled tasks receive a fresh root context per execution, which prevents one iteration of schedule:work from leaking registered Context Flow values into the next task.

Logging and exceptions

Laravel already injects Laravel Context into logs. This package does not add another Monolog processor.

will naturally include the Context Flow IDs through Laravel's Context logging integration.

Exception trackers can implement:

The package deliberately does not force Sentry/Bugsnag/Rollbar dependencies.

OpenTelemetry

Context Flow owns application correlation metadata, not tracing.

It never overwrites:

A TelemetryBridge contract and a no-op implementation are included so an application-specific bridge can be bound without coupling the package to one OpenTelemetry SDK version.

Baggage format

Application metadata is transported using a conservative W3C-baggage-compatible key/value representation:

The built-in codec intentionally supports the common key/value subset. It does not attempt to interpret vendor-specific baggage properties.

Limits and overflow

Defaults:

In non-production environments the published config defaults to throw, which catches oversized contexts early. Production defaults to dropping lower-priority application keys before transport metadata.

Sensitive key protection

Common credential names are denied even if accidentally configured:

This is a secondary safety net, not a replacement for explicit key registration.

Diagnostics

Inspect the current state:

Validate configuration:

The doctor checks signing configuration, risky public keys, sensitive-looking propagated keys, host configuration and header size limits.

Enable debug diagnostics:

Debug logging records boundary transitions, rejection reasons and propagated header names, but not baggage values.

Testing helpers

Use the provided trait in package/application tests:

The repository includes regression tests for UUID generation, baggage parsing, signing, trust resolution, snapshot filtering, execution rotation, queue filtering and HTTP injection.

Octane / long-running workers

No per-request values are stored in package singletons. Execution state lives in Laravel Context. At each HTTP/scheduled root boundary, package-managed and registered keys are reset before new IDs are created. Queue jobs rely on Laravel's hydration lifecycle, which flushes and hydrates Context per job.

If another package stores unscoped mutable state outside Laravel Context, that package must still handle its own worker reset lifecycle.

Extension points

Replace bindings in your application service provider when needed:

Other extension contracts include IdGenerator, ContextEnricher, Carrier, TelemetryBridge and ExceptionContextReporter.

HTTP value semantics

Context values propagated through HTTP baggage are transport metadata and are reconstructed as strings on the receiving service. Keep cross-service context scalar, small, and type-agnostic; if your domain requires an integer or enum, validate and cast it at the application boundary. Queue propagation uses Laravel Context natively and therefore preserves serializable PHP value types.

Security model

Context Flow guarantees policy enforcement around its own registered keys and transports. It does not guarantee authenticity of unsigned headers, does not replace authentication/authorization, and cannot stop application code from manually sending sensitive data in unrelated HTTP headers.

See SECURITY.md for the threat model.

Development

The GitHub Actions matrix tests Laravel 12/13 across compatible PHP versions.

License

MIT.


All versions of laravel-context-flow with dependencies

PHP Build Version
Package Version
Requires illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/events Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/log Version ^12.0|^13.0
illuminate/queue Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
php Version ^8.2
psr/http-message Version ^1.1|^2.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 abdulsalam/laravel-context-flow contains the following files

Loading the files please wait ...