Installation and Setup

Edit on

Composer

To install through Composer, run the following command:

composer require rawilk/laravel-modules

The package will automatically register a service provider and alias.

You can optionally publish the package’s configuration file by running:

php artisan vendor:publish --provider="Rawilk\LaravelModules\LaravelModulesServiceProvider"

Autoloading Modules

By default the modules are not loaded automatically. You can autoload the modules by using psr-4 in your composer.json file:

{
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Modules\\": "Modules/"
        }
    }
}
  • If you changed the module namespace in the config file, be sure to change "Modules\\" to your new namespace.
  • If you changed the directory where the modules get stored in the config file, be sure to change "Modules/" to the directory they will be stored in.

Tip:

Be sure to run composer dump-autoload afterwards.