Create a module
To generate a new, enabled module in Modules/Blog, run module:make. Prerequisites: the package is installed (see Installation) and composer is on your PATH, because module:make runs composer dump-autoload.
Create a web module
Section titled “Create a web module”php artisan module:make BlogThis creates Modules/Blog with its folders, module.json, composer.json, service providers, a controller, views, routes, and a seeder, then prints Module [Blog] created successfully.
Choose another module type
Section titled “Choose another module type”Pass a type flag to change the generated scaffold:
-
API module (
--api): generates a JSON controller alongside the standard web files.Terminal window php artisan module:make Blog --api -
Plain module (
--plain/-p): creates only the folders andmodule.json, with no providers, routes, views, orcomposer.json.Terminal window php artisan module:make Blog --plain -
Inertia module (
--inertia): creates an Inertia controller andIndex,Create,Show, andEditpages inresources/js/Pages, without Blade views. The framework followsinertia.frontendinconfig/modules.php(defaultvue); see Use Inertia in a module.Terminal window php artisan module:make Blog --inertia
Web is the default. Passing --web overrides --plain and --api. Do not combine --plain with --api (the combination also falls back to a web module).
Create several modules at once
Section titled “Create several modules at once”Pass multiple names to generate several modules in one command. Every flag applies to all of them:
php artisan module:make Blog Shop --apiCreate a module that starts disabled
Section titled “Create a module that starts disabled”Add --disabled (-d) to leave the new module disabled until you enable it with module:enable:
php artisan module:make Blog --disabledSet the author and vendor
Section titled “Set the author and vendor”Override the author and vendor written to the module’s composer.json:
php artisan module:make Blog --author-name="Jane Doe" --author-email=jane@example.com --author-vendor=acmeThis sets the package name to acme/blog. To change defaults for every new module, set MODULE_VENDOR, MODULE_AUTHOR_NAME, and MODULE_AUTHOR_EMAIL in .env, or edit the composer section of config/modules.php.
Overwrite an existing module
Section titled “Overwrite an existing module”module:make stops if the module already exists. Pass --force to delete the existing module folder and regenerate it from scratch:
php artisan module:make Blog --forceCheck the result
Section titled “Check the result”List your modules:
php artisan module:listStatus / Name ........................................ Path / priority[Enabled] Blog ................................... Modules/Blog [0]Modules created with --disabled show [Disabled]. For web and API modules, run php artisan route:list --name=blog to see the generated blog.* web routes (no authentication required) and api.blog.* API routes (protected by auth:sanctum).
Related
Section titled “Related”module:makeand the other generator commandscomposerconfiguration keys- Enable and disable modules
- Delete a module
- Change the folder layout of modules
- Anatomy of a module: what
module:makegenerates and why