Context information passing abstraction for PHP

1.1.0 2022-10-28 11:05 UTC

This package is auto-updated.

Last update: 2023-11-28 13:25:24 UTC


php-workflow code-coverage

Context passing abstraction for modern PHP projects, inspired in Golang's context package.


composer require castor/context

Quick Start


use Castor\Context;

// This is a default base context
$ctx = Context\nil();

// This returns a new context with the passed values stored
$ctx = Context\withValue($ctx, 'foo', 'bar');

// Later in the call stack
echo $ctx->value('foo'); // Prints: bar

To learn about the rationale behind this library, best practices when using it and implementation examples, check the documentation.