module.json
This page describes three JSON files: the module.json manifest of a module, the composer.json of a module, and the modules.json file of an application.
module.json
Section titled “module.json”Each module has a module.json file in its root folder. module:make writes it from the json stub. The package finds modules by globbing module.json in every scanned folder (see paths.modules and scan in Configuration).
The module status (enabled or disabled) is not stored in module.json. The activator stores it. See activators in Configuration.
A file generated by module:make Blog:
{ "name": "Blog", "alias": "blog", "description": "", "keywords": [], "priority": 0, "providers": [ "Modules\\Blog\\Providers\\BlogServiceProvider" ], "files": []}Fields
Section titled “Fields”| Field | Type | Written by module:make |
Read by the package | Effect |
|---|---|---|---|---|
name |
string | yes: the studly-case module name | yes | Identifies the module. The repository indexes modules by the lower-case name, so lookups ignore case. The activator uses it as the key of the statuses file. |
alias |
string | yes: the lower-case name | no | No effect. |
description |
string | yes: empty | yes | Returned by Module::getDescription(), or "" when missing. |
version |
string, integer, or float | no | yes, by ModulesEndpoint |
Exposed as a string on GET /actuator/modules and GET /actuator/modules/{name}. Empty or non-scalar values report null. |
keywords |
array | yes: empty | no | No effect. |
priority |
integer | yes: 0 |
yes | Sort key. Enabled module providers register in ascending order. module:list --only=priority and database --direction sort by it. Module::getPriority() returns a string, defaulting to 0. |
providers |
array of class names | yes: the main service provider | yes | Providers registered for each enabled module via Laravel’s ProviderRepository. Omitted by module:make for plain modules or when provider.generate is false. |
aliases |
object | no | yes | Class aliases (alias => class) registered with Laravel’s AliasLoader for each enabled module. |
files |
array of paths | yes: empty | yes | PHP files, relative to the module root, included (include_once) when the package registers enabled modules. |
migration |
object | no | yes | Optional. Holds path and seeds, described below. |
active |
integer | no | only by module:v6:migrate |
Legacy v5 field. 1 enables and 0 disables the module when module:v6:migrate runs. |
migration keys
Section titled “migration keys”| Key | Type | Effect |
|---|---|---|
migration.path |
string | Migration folder relative to the module root. Overrides the migration generator path for migration commands. |
migration.seeds |
array of class names | Seeders that module:seed runs. When present, module:seed skips <Module>DatabaseSeeder. |
Every other field is available through Module::get($key, $default). The package ignores fields not listed above.
Module composer.json
Section titled “Module composer.json”module:make writes a composer.json in the module root from the composer stub, unless composer is removed from stubs.files or the module is plain.
The package reads these keys, through Module::getComposerAttr($key, $default):
| Key | Read by | Effect |
|---|---|---|
require |
module:update |
Packages installed with composer require in the application. |
require-dev |
module:update |
Packages installed with composer require --dev in the application. |
scripts |
module:update |
Merged into the scripts of the application composer.json. |
autoload.psr-4 |
module:composer-update |
The legacy key <namespace>\<Module>\App\ is rewritten to <namespace>\<Module>\. |
A file generated by module:make Blog with the default configuration:
{ "name": "nwidart/blog", "description": "", "authors": [ { "name": "Nicolas Widart", "email": "n.widart@gmail.com" } ], "extra": { "laravel": { "providers": [], "aliases": {} } }, "autoload": { "psr-4": { "Modules\\Blog\\": "app/", "Modules\\Blog\\Database\\Factories\\": "database/factories/", "Modules\\Blog\\Database\\Seeders\\": "database/seeders/" } }, "autoload-dev": { "psr-4": { "Modules\\Blog\\Tests\\": "tests/" } }}The values come from composer.vendor, composer.author, namespace and paths.app_folder. See Configuration.
modules.json
Section titled “modules.json”modules.json is an optional file in the application root. module:install, called without a name argument, reads it and installs each module of its require list. See module:install.
{ "require": [ { "name": "acme/blog", "version": "1.2.0", "type": "github-https", "path": "Modules/Blog" } ]}Fields of a require entry
Section titled “Fields of a require entry”| Field | Required | Description |
|---|---|---|
name |
yes | Package name in the form vendor/name. |
version |
no | Composer version constraint, or the Git branch, tag or commit to check out. |
type |
no | Install source: composer, empty, github, github-https, gitlab, bitbucket, a URL with a scheme (including file://), or user@host. Falls back to --type. See module:install. |
path |
no | Destination folder, relative to the application root when relative. Ignored for composer installs. Empty or non-string values fall back to --path (for a single entry) or the default module folder. |
require must be a list of objects, each with a non-empty string name. version and type must be scalars when set. Invalid entries are skipped with an error line naming their position. The remaining entries still install, and the command exits with 1. A non-list require prints one error line and exits with 1. See module:install for exact messages.
modules.json has no other field. It is a different file from modules_statuses.json, which the file activator writes.