F
F
FOGstudio2014-07-24 15:35:27
Laravel
FOGstudio, 2014-07-24 15:35:27

Laravel 4: how to implement HMVC?

I want to implement an HMVC architecture such that it would be possible to embed HMVC components in a template, and the folder structure would be components/user/models, components/user/views, components/user/controllers. Suggest the best options, examples.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexAtr, 2014-07-27
@FOGstudio

I created a modular structure like this: I
created a modules folder, in it all the folders were named with a capital letter, to use psr-4. For example: modules/Api/Controllers. If you do not use autoload, each time adding a new file you will have to run composer dump.
To create namespaces in views and include files like filters.php/routes.php, each module has its own service provider.
Add a namespace for the view:

\View::addNamespace($module['name'],$module['path'].'/views');

This is how the namespace is used:
Accordingly, a class from another module is connected like this:
Backend\Models\Source::find($id);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question