New Laravel 11 Apps Include a Health Check Endpoint
Last updated on by Paul Redmond
As part of the release of Laravel 11, new applications include a health /up
endpoint. This route is defined in the new bootstrap/app.php
file by passing the health parameter—which is defined by default in the Laravel 11 skeleton:
Application::configure(basePath: dirname(__DIR__)) ->withProviders() ->withRouting( web: __DIR__.'/../routes/web.php', // api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', // channels: __DIR__.'/../routes/channels.php',+ health: '/up', ) // ...
When setting up the application routing, the Laravel framework defines the health route and also emits a DiagnosingHealth
event:
use Illuminate\Foundation\Events\DiagnosingHealth; // ... if (is_string($health)) { Route::middleware('web')->get($health, function () { Event::dispatch(new DiagnosingHealth); return View::file(__DIR__.'/../resources/health-up.blade.php'); });}
The route is configurable with the default /up
endpoint and returns an animated “Application up” health page in the browser: