setono/sylius-static-contexts-bundle
A Sylius bundle for defining static contexts and reusing them throughout your store, simplifying configuration and keeping context-dependent behavior consistent across channels, locales, and other store settings.
StaticChannelContext and StaticLocaleContext solve a small but recurring problem — Sylius resolves channel/locale from the request, which doesn't exist in CLI commands, message-queue consumers, cron jobs, or test fixtures. This package is a thin, purpose-built adapter; the alternative is hand-rolling per-project context switching that every team reimplements and re-debugs. Adopt rather than build.reset(), null-unsetting, DI registration, and tag priorities gives confidence for multi-channel/multi-locale stores where a leaked static context could silently serve the wrong locale. That reduces the risk profile of supporting many channels per deployment.1.x branch, which should be logged as technical debt with an owner and a deadline.Consider adopting when all of the following hold:
1.x; v2.0.0 will not install.Look elsewhere or skip it when:
Also note the practical caveat: static/global context must be reset between jobs in long-running workers. The release adds tests around reset() and null-unsetting, which is a positive signal, but the responsibility for calling it remains yours. Treat that as an engineering requirement, not an optional nicety.
For executives: This is a routine maintenance release of a small utility library that lets our background jobs, scheduled tasks, and API endpoints correctly resolve which store and language they're operating on — the same way the website does automatically. The new version requires us to be on the current major versions of our platform (PHP 8.2, Symfony 6.4+, Sylius 2), which aligns with where we're already heading. There is no rewrite: the migration guide states no application code changes are needed. The decision it informs is when, not whether, to complete the platform upgrade — and it adds a small, low-risk dependency to that plan rather than a new project.
For engineering: v2.0.0 is a dependency and tooling upgrade, not a feature release. PHP floor moves to 8.2; Symfony to ^6.4 || ^7.4; Sylius to v2; symfony/service-contracts to ^3.0. Service config moved from XML to PHP because XmlFileLoader is deprecated in Symfony 7.4 — expect that pattern in other bundles too. Psalm has been swapped for PHPStan at level 9 with strict, Symfony, PHPUnit, deprecation, and prophecy extensions; PHPUnit 11 and Rector 2 (UP_TO_PHP_82) are in place. The public API (StaticChannelContext, StaticLocaleContext) is unchanged in both interface and behavior. New tests cover reset(), null-unsetting, DI service registration and tag priorities, and the bundle class — so the risky area for us (context leaking across queued jobs) now has explicit coverage. Upgrade is composer require setono/sylius-static-contexts-bundle:^2.0 once the platform requirements are met; otherwise pin to 1.x and track it as debt. Validate the Symfony ^7.4 constraint against your actual installed version before bumping, and confirm reset() is invoked in every long-running consumer.
How can I help you explore Laravel packages today?