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();
For checking open the following URL:
http://localhost:8000/up
Output:
You might also like:
Top comments (0)