DEV Community

Techsolutionstuff
Techsolutionstuff

Posted on • Originally published at techsolutionstuff.com

Laravel 11: Health Check Routing Example

In this article, we'll see how to health routing in laravel 11.

New Laravel 11 applications include a health routing directive, which instructs Laravel to define a simple health-check endpoint that may be invoked by third-party application health monitoring services or orchestration systems like Kubernetes.

By default, this route is served at /up. When HTTP requests are made to this route, Laravel will also dispatch a DiagnosingHealth event.

So, let's see laravel 11: health check routing example, health routing in laravel 11.

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();
Enter fullscreen mode Exit fullscreen mode

For checking open the following URL:

http://localhost:8000/up
Enter fullscreen mode Exit fullscreen mode

Output:

Laravel 11: Health Check Routing Example


You might also like:

Read Also: How to Create Interface in Laravel 11

Top comments (0)