Laravel - Multi-Module Development

Laravel framework of relatively large, more suitable for relatively large projects.

To clear the entire project file structure, divided into different parts of different modules necessary.

 

A mounting extended package

1, depending on the version Laravel, select extended package version.

  packagest link -  https://packagist.org/packages/nwidart/laravel-modules

2, with the composer command to download and install the extension bags

  composer require nwidart/laravel-modules

  Automatically registered service providers and aliases, and automatically creates the artisan command module related.

  Modules will automatically create a directory in the root directory of the project.

3, the configuration file generated

  php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

  Generates modules.php in the config directory

 

Second, create a module

1, created with artisan command

  php artisan module:make Name

  Name is the name of the module

  Name directory is automatically created in the Modules directory and contains the entire code.

  You can create multiple

2, load modules

  Composer.json modify files, it will automatically load the Modules added.

     {
          "autoload": {
            "psr-4": {
              "App\\": "app/",
              "Modules\\": "Modules/"
            }
          }
        }

  After the execution composer modify command to make it work.

  composer dump-autoload

 

Guess you like

Origin www.cnblogs.com/rendd/p/11616900.html