Thursday, December 5, 2024
HomePHPNew Laravel 11 Apps Embrace a Well being Test Endpoint

New Laravel 11 Apps Embrace a Well being Test Endpoint


As a part of the discharge of Laravel 11, new functions embody a well being /up endpoint. This route is outlined within the new bootstrap/app.php file by passing the well being parameter—which is outlined by default within the Laravel 11 skeleton:

Software::configure(basePath: dirname(__DIR__))

->withProviders()

->withRouting(

net: __DIR__.'/../routes/net.php',

// api: __DIR__.'/../routes/api.php',

instructions: __DIR__.'/../routes/console.php',

// channels: __DIR__.'/../routes/channels.php',

+ well being: '/up',

)

// ...

When establishing the appliance routing, the Laravel framework defines the well being route and likewise emits a DiagnosingHealth occasion:

use IlluminateFoundationEventsDiagnosingHealth;

 

// ...

 

if (is_string($well being)) {

Route::middleware('net')->get($well being, perform () {

Occasion::dispatch(new DiagnosingHealth);

 

return View::file(__DIR__.'/../sources/health-up.blade.php');

});

}

The route is configurable with the default /up endpoint and returns an animated “Software up” well being web page within the browser:

Laravel 11 health page
The Laravel 11 well being web page



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments