phpmentors/route-based-session-configuration-bundle
Configures PHP session settings on a per-route basis in Symfony applications. Define session options per route to control cookie, storage, and lifetime behavior without global configuration.
RouteBasedSessionConfigurationBundle is a Symfony bundle (v1.1.0 targets Symfony >=2.8, 3.x, and now 4.x). It has no Laravel service provider, no facade, no config/session.php integration, and no auto-discovery. There is nothing to composer require and boot in a Laravel app.DependencyInjection/Configuration.php (to see the config tree), the route-to-session-options mapping node in the bundle config, and the event listener/subscriber that mutates session options per request. That listener is the piece you will be re-implementing in Laravel.remember sessions on marketing pages vs. short-lifetime sessions on checkout/admin, or a separate cookie name per tenant/subdomain. That is the real-world need this package solves on Symfony.StartSession in the web group. Budget under an hour.If you are actually in a Symfony app (v1.1.0):
app/AppKernel.php (Symfony 2.8/3.x) or config/bundles.php (Symfony 4).config.yml / config/packages/*.yaml; the listener applies the matching entry before the session starts.The Laravel equivalent (recommended pattern):
// app/Http/Middleware/RouteSessionConfig.php
public function handle($request, Closure $next)
{
$rules = config('session-routes'); // pattern => [cookie, lifetime, driver, ...]
foreach ($rules as $pattern => $options) {
if ($request->is($pattern)) {
config(array_merge(config('session'), $options));
break;
}
}
return $next($request);
}
Kernel::$middlewareGroups['web'] above \Illuminate\Session\Middleware\StartSession::class. Middleware order in that array is execution order, so pushing it after StartSession silently does nothing.cookie name over mutating session config mid-request; session identity is derived from the cookie name.$this->withSession([...])->get(...) plus assertions on Set-Cookie headers, and add one negative test proving a non-matching route keeps default settings.laravel/framework support, no service provider, no published config. It cannot be the dependency; use it as a design reference only.2.8.0 | 3.0.0 | 4.0.0 or greater. Projects on Symfony ≤2.7 lost support — check composer.lock before upgrading a legacy app.config/bundles.php; Symfony 3/2.8 use AppKernel. Mixing these up yields a "bundle not registered" error far from the root cause.bin/console cache:clear; if the listener isn't cache-warmable you'll see stale behaviour in prod but not dev.StartSession.How can I help you explore Laravel packages today?