bootstrap/app.php

bootstrap/app.php and the Fluent Application Builder

Since Laravel 11 2,157 the kernels, the exception handler and most providers no longer live in app/; one fluent chain in bootstrap/app.php configures them:

bootstrap/app.php in Laravel 13.33.0 (use lines omitted)PHP
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware): void {
        //
    })
    ->withExceptions(function (Exceptions $exceptions): void {
        $exceptions->shouldRenderJsonWhen(
            fn (Request $request) => $request->is('api/*') || $request->expectsJson(),
        );
    })->create();

configure() returns an ApplicationBuilder that has already bound both kernels and queued bootstrap/providers.php. The rest only queues work too: withRouting() loads route files in a booting callback (Route Files), withMiddleware() runs when the HTTP kernel is resolved (Registering Middleware), and withExceptions() when the exception handler is. Other methods include withSchedule(), withBindings() and booted(). The /up health route stays exempt from maintenance mode, so load-balancer checks still pass.