Enable and disable modules
Change a module’s status to turn it on or off. A disabled module stays on disk, but the package does not register its service providers or routes.
Disable a module
Section titled “Disable a module”php artisan module:disable BlogThe command prints Disabling Blog Module, old status: Enabled.
Enable a module
Section titled “Enable a module”php artisan module:enable BlogChange several modules
Section titled “Change several modules”Pass multiple names, or use --all to target every module:
php artisan module:disable Blog Shopphp artisan module:enable --allIf any name does not exist, the command stops before changing anything. It prints an error (such as ERROR Module [Nope] does not exist.) and exits with status 1.
Change the status from PHP code
Section titled “Change the status from PHP code”use Nwidart\Modules\Facades\Module;
Module::disable('Blog');Module::findOrFail('Blog')->enable();Check the current status with Module::isEnabled('Blog').
Status changes take effect on the next HTTP request or Artisan run, because module providers register during boot.
Where the status is stored
Section titled “Where the status is stored”The default activator writes statuses to modules_statuses.json in the application root. Any module missing from that file counts as disabled, including modules discovered from extra scan paths or vendor/ (see Load modules from extra locations).
To store statuses elsewhere, see Store module status with a custom activator.
Check the result
Section titled “Check the result”php artisan module:listEach module shows [Enabled] or [Disabled]. Add --only=enabled to list enabled modules only. Run php artisan route:list --name=blog to confirm routes disappear while Blog is disabled.
Related
Section titled “Related”module:enable,module:disableandmodule:list- Events:
enabling,enabled,disablinganddisabled - Repository API
- Expose the modules on the actuator: read which modules are enabled over HTTP
- Create a module
- Delete a module
- Module status and activators: why the status is not in
module.json, and whether to commit the statuses file