tourze/symfony-runtime-context-bundle
A Symfony bundle for managing runtime context in your application. It offers a lightweight way to store and access request- or execution-scoped values, helping services share contextual data without tight coupling.
composer require tourze/symfony-runtime-context-bundle.config/bundles.php:
Tourze\Symfony\RuntimeContextBundle\RuntimeContextBundle::class => ['all' => true],
README.md and src/ — specifically the bundle class, the context service interface, and any compiler pass. The public service ID is what you'll inject everywhere else.Note on 1.0.1: the release notes only link the GitHub compare (
1.0.0...1.0.1). Treat this as a patch bump. Read the diff at the link before adopting, and pin^1.0rather than an exact version while you validate.
Laravel caveat: this is a Symfony bundle, not a Laravel package. It is not auto-discovered by Laravel and has no service provider. In a Laravel app you have three realistic options:
ServiceProvider.For plain PHP (non-framework) usage, check whether the context class is usable standalone — that is usually the cleanest port.
kernel.request listener or Laravel middleware. Everything downstream reads from the injected context service.extra. This is usually the highest-value integration and the reason teams install a context bundle.trace_id/span_id into the context at the request boundary; emit them in every log line and error report. Pairs cleanly with OpenTelemetry.RequestContext argument through dozens of constructors, decorate the few entry-point services and set context there.setUp(), clear and seed the context with fixtures. Assert against a fake or against the real service if it's cheap. Always clear in tearDown().composer require "just works" in Laravel. Confirm a service provider exists or write a bridge; otherwise Symfony's container wiring will never run.tearDown() unconditionally.__construct(RuntimeContext $ctx) will fail with "cannot autowire." Check services.yaml / the bundle's extension for the alias and bind to the interface.1.0.0...1.0.1 before bumping in production; patch releases on young bundles sometimes carry small API or container-config tweaks. Pin ^1.0 and run your test suite against the bump.prod/dev. Double-check the bundle doesn't auto-register a processor in test, or assertion output gets noisy.How can I help you explore Laravel packages today?