在thinkphp目录执行
php think make:middleware Check
生成的文件
<?php
namespace app\http\middleware;
class Check
{
public function handle($request, \Closure $next)
{
echo '我就是中间件';
return $next($request);//结尾必须这样
}
}
配置middleware.php
<?php
return[
app\http\middleware\Check::class
];
//后置中间件
public function handle($request, \Closure $next)
{