請問應(yīng)用插件(plugin)的正常執(zhí)行流程里會執(zhí)行全局中間件么?
webman/admin
并登錄后臺redis-queue管理
應(yīng)用插件新建中間件app/middleware/Test.php
class Test implements MiddlewareInterface
{
public function process(Request $request, callable $handler) : Response
{
echo $request->url() . PHP_EOL;
echo 'TestMiddleware' . PHP_EOL;
$response = $handler($request);
return $response;
}
}
config/middleware.php
配置文件
return [
'' => [
app\middleware\Test::class,
]
];
php start.php start
app/admin
應(yīng)用不會執(zhí)行全局中間件。app/queue
應(yīng)用下的控制器,有一定的機(jī)率會執(zhí)行全局中間件。這個結(jié)果讓我有點(diǎn)懵。目前問題我也無法針對性的復(fù)現(xiàn),開發(fā)過程中,訪問后臺app/queue
下的控制器時不時的會執(zhí)行全局中間件。我看app/queue
下的路由配置里,有個閉包路由:
Route::any('/app/queue', function () {
return response()->withFile(base_path() . '/plugin/queue/public/index.html');
});
看請求url//127.0.0.1:8787/app/queue
及請求控制器名稱為空
,貌似是這個閉包路由執(zhí)行了全局中間件?但時有時無。。
求解惑,謝謝!