Lumen bootstrap/app.php provider and middleware registration during upgrade to Laravel
0 reputation · 06 Jul 2022, 19:59 UTC
0 reputation · 06 Jul 2022, 19:59 UTC
Migrate an existing Lumen API project to a full Laravel installation while preserving the middleware and service providers currently enabled by uncommenting entries in bootstrap/app.php.
Lumen registers middleware and providers directly in bootstrap/app.php, whereas Laravel uses app/Http/Kernel.php and config/app.php. The documented upgrade path involves Composer dependency changes and directory restructuring, but it does not specify whether every Lumen-enabled provider maps one-to-one to Laravel or whether some require facade aliases, boot-order adjustments, or replacement.
Assuming migration from Lumen 10.x to Laravel 10.x or 11.x, it is unclear which providers and middleware classes survive the transition unchanged and which behave differently under Laravel's full request lifecycle.
Does middleware enabled in Lumen's bootstrap/app.php transfer directly to Laravel's global middleware stack? Which service providers require re-registration in config/app.php rather than simple copying? Are there Lumen-only providers with no Laravel equivalent that must be replaced before upgrading?
When moving a Lumen 10.x API to Laravel 10 or 11, the lines you uncomment in bootstrap/app.php are not copied over. Laravel expects middleware in app/Http/Kernel.php and service providers in config/app.php (Laravel 10) or bootstrap/providers.php (Laravel 11).
$app->middleware([...]) and providers via $app->register(Provider::class). Laravel does not use bootstrap/app.php for these registrations.Illuminate\Http\Request and return a response work unchanged; only their registration location changes.Illuminate\Lumen\Providers have no Laravel equivalent and must be replaced by Laravel’s core providers (e.g., AuthServiceProvider, RouteServiceProvider).Most third‑party providers enabled in Lumen map one‑to‑one to Laravel and can be re‑registered in the provider config. Providers that rely on Lumen‑specific features (e.g., direct router access) may need boot‑order tweaks or facade aliases because Laravel loads a full request lifecycle with sessions, views, events, and broadcasting enabled by default.
$app->middleware and $app->register from bootstrap/app.php into a temporary list.$middleware in app/Http/Kernel.php.$middlewareGroups['api'].$routeMiddleware (key → class).Illuminate\Lumen\Providers and replace it with the Laravel counterpart (e.g., Illuminate\Lumen\Providers\AuthServiceProvider → Illuminate\Auth\AuthServiceProvider).config/app.php → 'providers'.bootstrap/providers.php (return array).$app->router or other Lumen internals, replace $app with $this (the container) and remove Lumen‑only calls.php artisan config:cache after changes to catch mis‑ordered dependencies.config/app.php → 'aliases' (Laravel 10) or the appropriate facade service provider (Laravel 11).php artisan route:list to confirm routes.bootstrap/app.php (Laravel ignores it).To finalize the mapping, could you share the exact list of middleware and provider classes currently enabled in your bootstrap/app.php? This will let us confirm which are Lumen‑only and which can be copied verbatim.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.