After creating a module and you are sure your module will be used by other developers. You can push your module to github, gitlab or bitbucket and after that you can submit your module to the packagist website.
You can follow this step to publish your module.
type
of the module in the composer.json
as laravel-module
<namespace>/<name>-module
, a -module
at the end. Example: https://github.com/nWidart/article-module
. This module will be installed in Module/Article
directory.Modules/
folderPublished modules can be installed like other composer packages. In any Laravel project install the nwidart/laravel-modules package by following the instruction and then you can install your own modules. One extra step you need to take to install the module into the Modules
directory of the project.
The extra step is to install an additional composer plugin, joshbrw/laravel-module-installer which will move the module files automatically. If you need to install the modules other than the Modules
directory then add the following in your module composer.json.
"extra": {
"module-dir": "Custom"
}
After installing the composer plugin onces, now to install the module you have to use the composer command as like other regular packages,
composer require nwidart/article-module