如何在 Laravel 5 中制作 HMVC?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30736545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make HMVC In Laravel 5?
提问by nirajan poudel
I have finished my previous project in yii2. Now, I'm currently working on laravel 5. I am new to laravel 5. I have googled about HMVC in laravel but I haven't found an appropriated answer (ie package) on Laravel. In Yii2 it provided by default .But I have not found in Laravel .Please suggest me How I work moduler way in Laravel 5.
我已经在 yii2 中完成了我之前的项目。现在,我目前正在研究 Laravel 5。我是 Laravel 5 的新手。我在 Laravel 中搜索了有关 HMVC 的信息,但我没有在 Laravel 上找到合适的答案(即包)。在 Yii2 中它默认提供。但我在 Laravel 中没有找到。请建议我如何在 Laravel 5 中以模块方式工作。
回答by num8er
You can achieve this by using namespaces and grouping routes. Look at my screenshot:
您可以通过使用命名空间和分组路由来实现这一点。看我的截图:
As You can see I've 2top level namespaces: Panel
, Site
.
It's not problem to make controllers with namespace SomeApp
, SomeAnotherApp
and group their routes. using Route::group
.
如您所见,我有2 个顶级命名空间:Panel
, Site
. 这不是问题与命名空间化妆控制器SomeApp
,SomeAnotherApp
和组他们的路线。使用Route::group
.
also read this discussion: https://laracasts.com/discuss/channels/requests/multiple-modules-in-laravel-5?page=1
另请阅读此讨论:https: //laracasts.com/discuss/channels/requests/multiple-modules-in-laravel-5?page=1