switon / context
Runtime context isolation with scoped state for Switon Framework
v1.0.0
2026-05-09 16:52 UTC
Requires
- php: >=8.3
- psr/event-dispatcher: ^1.0
- switon/core: ^1.0
- switon/event: ^1.0
Requires (Dev)
- switon/testing: ^1.0
README
Runtime context isolation and scoped state for Switon Framework.
Installation
composer require switon/context
Requirements: PHP 8.3+
Quick Start
use Switon\Core\Attribute\Autowired; use Switon\Core\ContextAware; use Switon\Core\ContextManagerInterface; class ExampleViewContext { public array $vars = []; } class ExampleView implements ContextAware { #[Autowired] protected ContextManagerInterface $contextManager; public function getContext(): ExampleViewContext { return $this->contextManager->getContext($this); } public function setVar(string $name, mixed $value): void { $this->getContext()->vars[$name] = $value; } }
Docs: https://docs.switon.dev/latest/context
License
MIT.