Laravel 11 New a Health Check Route Example

By Hardik Savani April 16, 2024 Category : Laravel

In this short article, we will show you a new health check endpoint in laravel 11 framework.

The release of Laravel 11 is around the corner and it is packed with a lot of new features and improvements. Laravel 11 comes with a slimmer application skeleton. Laravel 11 introduce streamlined application structure, per-second rate limiting, health routing etc.

With the launch of Laravel 11, fresh applications now come equipped with a health `/up` endpoint. This endpoint is established within the updated `bootstrap/app.php` file, incorporating the default `health` parameter integrated into the Laravel 11 skeleton.

bootstrap/app.php

<?php
  
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
   
return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        //
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();

During the setup of application routing, the Laravel framework establishes the health route.

You can run your app and open the following URL:

http://localhost:8000/up

You will see the following output:

I hope it can help you...

Shares