# Installation and Setup

On this page

Composer

To install through Composer, by run the following command:

composer require nwidart/laravel-modules

The package will automatically register a service provider and alias.

Optionally, publish the package's configuration and publish stubs by running:

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

To publish only the config:

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

To publish only the stubs

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

Autoloading

By default the module classes are not loaded automatically. You can autoload your modules using psr-4. For example :

{
  "autoload": {
    "psr-4": {
      "App\\": "app/",
      "Modules\\": "Modules/",
      "Database\\Factories\\": "database/factories/",
      "Database\\Seeders\\": "database/seeders/"
    }
  }
}

Tip: don't forget to run composer dump-autoload afterwards


Laravel Package built by Nicolas Widart.
Maintained by David Carr follow on X @dcblogdev