Context
Context passing abstraction for your PHP projects.
The context package provides a simple base class that serves as a context-passing abstraction for your PHP projects.
Installation
Add the Castor repository to your composer.json
.
{ "repositories": [{ "type": "composer", "url": "https://castor-labs.github.io/php-packages" }]}
And then install with composer.
composer require castor/context
Motivation
Currently, PHP doesn’t have a way of passing contextual information like request scoped values down the call stack.
Current solutions rely on shared state inside a service (like Symfony’s TokenStorageInterface
). This context
abstraction is a minimal contract that applications and libraries can implement to pass down request-specific information
down the call stack of an application in an explicit and immutable way.