The purpose of this package is to allow for easy installation of standalone Modules into the Laravel Modules package. This package will ensure that your module is installed into the Modules/
directory instead of vendor/
.
This a refactored version of joshbrw/laravel-module-installer
. It incorporates most of the PR's open since 2021.
- Ensure you have the
type
set tolaravel-module
in your module'scomposer.json
- If your package is named in the convention of
<namespace>/<name>-module
, for examplejoshbrw/user-module
, it will install by default toModules/User
. - Require this package:
composer require joshbrw/laravel-module-installer
- Require your bespoke module using Composer. You may want to set the constraint to
dev-master
to ensure you always get the latest version.
All options go into extra
of the application composer.json
option | type | default | |
---|---|---|---|
module-dir |
string | Modules |
Sets the directory name where modules are installed, defaults to Modules |
use-symlinks |
bool | false | Use symlinks instead of moving module directories from vendor to module-dir |
{
"extra": {
"module-dir": "Custom"
}
}
To change the default Modules
directory where the modules are installed, set the module-dir
in extra
of the applications composer.json
.
{
"extra": {
"use-symlinks": true
}
}
If set to true
, any Laravel module installed will be links to the Modules
directory instead of being moved from the vendor
directory
to the Modules
directory, e.g. ./Modules/SomePackage => ./vendor/some-name/some-package-module
.
All options go into extra
of the package composer.json
option | type | default | |
---|---|---|---|
module-name |
string |
Sets a custom module name | |
include-module-namespace |
bool |
false |
Includes the vendor (namespace) in the module directory path |
include-module-part |
bool |
false |
Does not remove the ending -module and becomes part of the module directory path |
By default, this package uses the <vendor>/<package-name>
structure as a base to determine the module's directory path. To
change this default behaviour, set the extra.module-name
to any custom name.
{
"extra": {
"module-name": "custom-module-name"
}
}
This will result in a module directory path called Modules/CustomModuleName
To include the package vendor name in the module's directory path, set the include-module-namespace
to true
(defaults to false
).
{
"extra": {
"include-module-namespace": true
}
}
Given vendor/some-module
will result in a module directory path called Modules/Vendor/Some
If a package name ends with -module
, this will be removed by default. If -module
should be part of the module directory path,
set include-module-part
to true
to incorporate it into its path.
{
"extra": {
"include-module-part": true
}
}
Given vendor/some-module
results in a module directory path called Modules/SomeModule
composer test
- When working on a module that is version controlled within an app that is also version controlled, you have to commit and push from inside the Module directory and then
composer update
within the app itself to ensure that the latest version of your module (dependant upon constraint) is specified in your composer.lock file.