Installation
To use Laravel Modules, install the package with Composer and register module autoloading in your application’s composer.json.
Requirements
Section titled “Requirements”- PHP 8.3 or later, with the
dom,json, andsimplexmlextensions. - Laravel 13 for version 13.x. See Version compatibility for other Laravel releases, Composer constraints, PHP versions, and support.
Install the package
Section titled “Install the package”-
Require the package.
Terminal window composer require nwidart/laravel-modulesThe package requires
wikimedia/composer-merge-plugin. Composer asks whether to trust it:Do you trust "wikimedia/composer-merge-plugin" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?]Answer
y. Composer adds this tocomposer.json:"config": {"allow-plugins": {"wikimedia/composer-merge-plugin": true}}If you answered
n, change the value fromfalsetotrue. If you answereddor Composer did not prompt, add the entry yourself. Composer skips module autoloading until you allow the plugin.Laravel discovers the service provider and the
Modulealias automatically. -
Tell the plugin where the modules live. Add the
merge-pluginentry to theextrasection ofcomposer.json(marked lines):"extra": {"laravel": {"dont-discover": []},"merge-plugin": {"include": ["Modules/*/composer.json"]}},Match the glob to the folder in
paths.modules(Configuration). The plugin merges each module’scomposer.jsoninto the application’s autoload configuration. See Autoloading and the Composer merge plugin for details. -
Regenerate the autoloader.
Terminal window composer dump-autoload -
Optional: publish the configuration file to
config/modules.php.Terminal window php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider" --tag=configThe package works without publishing it. See Configuration for every key.
-
Check the install.
Terminal window php artisan module:listWith no modules yet, the command prints only the header line:
Status / Name ........................................ Path / priority
If you used the "Modules\\": "Modules/" autoload entry from an older version, remove it from composer.json.
To build your first module, continue with Your first module.