作为 Laravel 11 发布的一部分,新的应用程序包括一个健康 /up
端点。此路由在新的 bootstrap/app.php
文件中定义,通过传递健康参数来定义 - 该参数默认在 Laravel 11 框架中定义
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', ) // ...
在设置应用程序路由时,Laravel 框架定义了健康路由,并发出一个 DiagnosingHealth
事件
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'); });}
该路由是可配置的,默认端点为 /up
,并在浏览器中返回一个动画的“应用程序正常运行”健康页面
