Build Structure Modules For Laravel.

Tram Ho

I. Introduction.

  • As you already know Laravel builds MVC with this model you won’t have many problems with small to medium projects. But on some bad day, you have to maintan the project a little bit bigger then you find it difficult to manage the project’s code, what should we do?
  • To solve the above problem, I will introduce to you the HMVC (Hierarchy – Model – View – Controller) model. With this model, you group code by function, each function will be a module. In each module is an MVC model full of model, view, controller and router. Thus code management is very easy.

II. Module configuration.

  • Laravel supports module configuration so the configuration is very easy without much difficulty for developers.
Step 1:

First, you have to create a folder containing modules that do not force you to name it, but most people call it Modules as shown below:

Step 2: Create ModuleServiceProvider.php

=> Then declare ModuleServiceProvider in app / config / app.php as shown:

Step 3: Create Module.

=> Now all functions of product are working properly.

III. End.

My post is done, hope it can help a little.

Thank you for reading my article. Thanks you !!

Share the news now

Source : Viblo