Utility commands
This page lists four commands that do not manage a single module’s lifecycle, generate a file, or touch the database.
Shared behaviour
Section titled “Shared behaviour”module:composer-update extends BaseCommand. It inherits the behaviour in Module management commands: variadic module, --all (-a), the interactive prompt, and exit status 1 on failure. module:setup, module:v6:migrate, and module:update-phpunit-coverage do not extend BaseCommand.
Each entry lists its arguments and its options. A command without arguments and options has no separate example: its synopsis is the example.
module:setup
Section titled “module:setup”Creates the modules directory and the public assets directory when they do not exist.
php artisan module:setupArguments
This command has no arguments.
Options
This command has no options.
Notes
- The command creates
paths.modules(defaultModules) andpaths.assets(defaultpublic/modules), with the permissions0755. - A directory that exists prints
Modules directory already existsorAssets directory already exists. The command exits with0in both cases.
module:composer-update
Section titled “module:composer-update”Rewrites the legacy autoload.psr-4 entry of a module composer.json so that the module namespace maps to the app folder.
php artisan module:composer-update [<module>...] [-a|--all]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module names. See Shared behaviour. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--all |
-a |
false |
Update every module. |
Notes
- Looks for
<modules namespace>\<Module>\App\or<modules namespace>\<Module>\<app folder namespace>\inautoload.psr-4. Replaces the key in place with<modules namespace>\<Module>\. Keeps the folder value, or setspaths.app_folderwhen empty. - A
composer.jsonwithout such a key stays unchanged. The command does not run Composer. The new mapping takes effect when Composer regenerates the autoloader, whichmodule:dumpandcomposer dump-autoloaddo. - The file keeps its key order, its empty objects and its trailing newline.
php artisan module:composer-update Blogmodule:v6:migrate
Section titled “module:v6:migrate”Copies the active field of each module.json (the version 5 way to store the status) into the activator.
php artisan module:v6:migrateArguments
This command has no arguments.
Options
This command has no options.
Notes
- For each module with
"active": 1the command enables the module. For"active": 0it disables the module. A module withoutactive, or with another value, is left alone. - The command prints
All modules have been migrated.and a table of the modules it changed. It always exits with0. - The command does not remove the
activefield.
module:update-phpunit-coverage
Section titled “module:update-phpunit-coverage”Syncs <source><include> in phpunit.xml with the app folders of enabled modules, removing entries for modules that are not enabled.
php artisan module:update-phpunit-coverageArguments
This command has no arguments.
Options
This command has no options.
Notes
- The command reads
phpunit.xmlin the application root and the statuses filemodules.activators.file.statuses-file(defaultmodules_statuses.json). - For each module with status
truewhose<paths.modules>/<Module>/<paths.app_folder>directory exists, it ensures a<directory suffix=".php">entry in<source><include>. - It removes the entries that point into
<paths.modules>/<Module>/<paths.app_folder>for a module that is no longer wanted. - The command edits the file line by line and keeps its formatting, indentation and line endings (LF or CRLF).
- New entries go where the file allows:
- In an existing multi-line
<include>block, before</include>. - In an empty
<include></include>or<include/>on one line inside<source>: the command expands it with the module entries only. - In
<source>with no<include>: inserts an<include>block containing<directory>./app</directory>and each enabled module. Supports multi-line<source>, empty<source></source>, self-closing<source/>or<source />(keeping attributes), and<source>with trailing elements on the same line (moved to a new line). <source><include>on one line with the rest on later lines: before</include>.- With no
<source>element, adds a<source>block before</phpunit>.
- In an existing multi-line
<directory>./app</directory>is the application’sappfolder, notpaths.app_folder. It is written only when creating a new<include>block.- Unsupported layouts: the whole block on one line (
<source><include><directory>...</directory></include></source>),...</directory></include>on one line, or<source/>with trailing text on the same line. The file stays unchanged, the command printsCould not find where to add the module entries in phpunit.xml: add them by hand., and omits the success line. - When it cannot remove an entry, it prints
Could not remove the entry [<path>] from phpunit.xml: remove it by hand. - The command prints
phpunit.xml updated with enabled module directories.only when it could place the entries. After a warning it still exits with0, so scripts that run it after each module change do not fail.
Exit status
| Status | Meaning |
|---|---|
0 |
Done, also after the warnings above. |
100 |
phpunit.xml does not exist. |
99 |
The statuses file does not exist. |
98 |
The command cannot decode the statuses file. Prints Error decoding JSON from <path>: <error>. See below. |
97 |
phpunit.xml is empty or not valid XML. |
Status 98 happens only when decoding the statuses file fails, in two cases:
- The file is empty or holds only whitespace.
FileActivatortreats that as no statuses and boots, but the command’s JSON decode fails. - The file holds invalid JSON and the active activator is not
FileActivator. The command still reads the file named bymodules.activators.file.statuses-file, and nothing else reads it at boot.
With a custom activator and a valid statuses file, the command exits with 0. With FileActivator and non-empty invalid JSON, the command never runs: FileActivator throws InvalidJsonException during boot and artisan exits with 1.