laravel通用和万能路由
作者:互联网
Route::any("/{module}/{controller}/{action}",function ($module,$class,$action){ $class = "App\\Http\\Controllers\\$module\\".ucfirst(strtolower($class)).'Controller'; if(class_exists($class)) { $ctrl = \App::make($class); return \App::call([$ctrl, $action]); } return abort(404); })->where([ 'module'=>'[0-9a-zA-Z]+','class' => '[0-9a-zA-Z]+', 'action' => '[0-9a-zA-Z]+']);
当没有模块目录时,可以不要$module及相关目录
标签:laravel,9a,App,万能,zA,module,action,class,路由 来源: https://www.cnblogs.com/dreamboycx/p/14784495.html