In Laravel 10, we had a RouteServiceProvider class that handled loading up all your different routes. This is a snippet from that file in an older project I worked on using Laravel 10:
RouteServiceProvider.php
/** * Define your route model bindings, pattern filters, and other route configuration. */ public function boot(): void { $this->configureRateLimiting(); $this->routes(function () { $this->registerCentralDomainRoutes(); config('app.env') == 'local' && Route::middleware('web')->group(base_path('routes/test.php')); }); } You had access to almost all of the tools and features of the Laravel framework in the ServiceProvider because the core framework services had already been booted up. But now, in Laravel 12, the RouteServiceProcivider file no longer exists and we now register routes in the bootstrap/app.php file.
bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: [ base_path('routes/web/routes.php'), base_path('routes/web/auth.php'), base_path('routes/web/agent.php'), ...(config('app.env') === 'local' ? [base_path('routes/web/test.php')] : [], ], api: base_path('routes/api.php'), commands: base_path('routes/console/routes.php'), health: '/up', ) This new system doesn't allow me to access values from the .env file, so I can't do things like conditionally registering routes like before.
How can I do this in Laravel 12?