bonnier/context-laravel
Laravel service provider and middleware for registering a request context. Install via Composer, add the ContextServiceProvider in config/app.php, and enable the RegisterContext middleware in Http/Kernel.php to make context available across your app.
stancl/tenancy), but the pattern is extensible for custom use cases.App\Http\Kernel) to ensure context is available across the request.stancl/tenancy instead.resolve() middleware or context managers (e.g., spatie/laravel-context) suffice?RequestContext).Illuminate\Http\Middleware stack.bind()/singleton() methods.Tenant::current()) may need updates.strict_types or attribute usage).config/app.php.App\Http\Kernel.php (e.g., Bonnier\Context\Middleware\ContextMiddleware).app()->bind(RequestContext::class, ...)).create_function).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Middleware not registered | Context unavailable | CI checks for middleware presence. |
| PHP version incompatibility | Runtime errors | Pin PHP version in phpunit.xml. |
| Context corruption | Inconsistent data across services | Immutable context objects. |
| Package abandonment | No security updates | Fork or replace with spatie/laravel-context. |
| Overuse in services | Tight coupling, testing complexity | Enforce context via interfaces, not concrete classes. |
Tenant::current()).How can I help you explore Laravel packages today?