美文网首页
Laravel 路由匹配所有请求

Laravel 路由匹配所有请求

作者: Xiaodongsu | 来源:发表于2016-10-10 10:03 被阅读0次

动态匹配所有

Route::group([], function () {
    Route::any('/{controller?}/{action?}', function($controller='', $action=''){
        if (empty($controller)) {
            return 'welcome!';
        }else {
            $controller = "App\\Http\\Controllers\\".ucfirst($controller).'Controller';
            return App::make($controller)->$action();
        }
    });
});

相关文章

网友评论

      本文标题:Laravel 路由匹配所有请求

      本文链接:https://www.haomeiwen.com/subject/qybmyttx.html