Generator commands
This page lists module:make, the 41 module:make-* generators and module:route-provider. Commands that manage existing modules are in Module management commands.
Shared behaviour
Section titled “Shared behaviour”Except for module:make (which creates a whole module), every command on this page generates a file inside a module. Two commands generate multiple files:
module:make-modelruns related generators for its flags (--controller,--factory,--migration,--request,--resource,--policy,--seed).module:make-componentalso runsmodule:make-component-view.
Arguments
Section titled “Arguments”nameis the first argument.module:make-controllernames itcontrollerandmodule:make-modelnames itmodel.module:make-event-providerandmodule:route-providertake no name argument.moduleis optional on every generator exceptmodule:make-class, where it is required. When omitted, the command uses the module stored bymodule:use. If none is stored or the stored module is missing, the command printsNo module given, and no module is set with module:use. Pass the module name, or run php artisan module:use <module> first., writes nothing, and exits with1.- An unknown module name prints
Module [Nope] does not exist., writes nothing, and exits with1. - Generators do not check whether the module is enabled.
Name handling
Section titled “Name handling”- Class names are converted to studly case. A
namewith/or\places the file in a sub-directory and matching sub-namespace (Admin/ReportcreatesReportunderAdmin). - An empty name, an absolute path, or a
..segment fails with exit status1. Segments that reduce to..after removing whitespace, hyphens, and underscores (such as. .) are also rejected. - Missing directories are created automatically.
Path and namespace
Section titled “Path and namespace”- Target folder:
<module path>/<paths.generator.<key>.path>. Each command’s<key>is in its notes. See Configuration. - Namespace:
<namespace>\<Module>\<generator namespace>. The generator namespace usespaths.generator.<key>.namespacewhen set, else the generator path withoutpaths.app_folder. Two exceptions apply:module:make-observerignorespaths.generator.observer.namespaceand always derives its namespace frompaths.generator.observer.path.module:make-scopederives its namespace from the last segment ofpaths.generator.model.pathplus\Scopes.
- The
generateflag of a generator key affects onlymodule:make, not individual generator commands.
Existing files
Section titled “Existing files”- An existing file stops the command with
File : <path> already exists.and exit status1. - Pass
--forceto overwrite an existing file. Every generator accepts-f|--force, exceptmodule:make-model(-fis--factory),module:route-provider, andmodule:make, which define--forcewithout a shortcut. Per-command tables omit--forceunless it differs.
Exit status
Section titled “Exit status”0 on success. 1 on an invalid name, an unknown or missing module, an existing file or any other error.
module:make
Section titled “module:make”Creates one or more modules: the folder structure, module.json, composer.json and the starting classes.
php artisan module:make <name>... [-p|--plain] [--api] [--web] [--inertia] [-d|--disabled] [--force] [--author-name=AUTHOR-NAME] [--author-email=AUTHOR-EMAIL] [--author-vendor=AUTHOR-VENDOR]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes, asked when missing | One or more module names. Repeatable. In an interactive terminal, a missing argument opens the prompt What is the name of the module?. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--plain |
-p |
false |
Generate a plain module: folders and module.json only. |
--api |
false |
Generate an API module (module:make-controller --api using controller-api.stub). All other stubs.files (views, routes, assets) are still written. |
|
--web |
false |
Generate a web module (default). Wins over --plain and --api. |
|
--inertia |
false |
Generate an Inertia module: an Inertia controller and four Inertia pages, no Blade views. | |
--disabled |
-d |
false |
Create the module in the disabled state. |
--force |
false |
Recreate the module when it already exists. | |
--author-name |
composer.author.name |
Author name written to composer.json. |
|
--author-email |
composer.author.email |
Author email written to composer.json. |
|
--author-vendor |
composer.vendor |
Vendor part of the package name in composer.json. |
Notes
- This command is not a generator in the sense of the shared behaviour above: it has no
moduleargument and does not readmodule:use. Withoutname, an interactive terminal asksWhat is the name of the module?. - The name is converted to studly case. It becomes the module folder and namespace. The converted name must match
^[A-Za-z_][A-Za-z0-9_]*$. A name that does not match prints an error, the command goes on with the next name, and the exit status is1. - Module type precedence (first match wins):
--web->web--plainwith--api->web--plain->plain--api->api- Default ->
web--inertiahas no effect on aplainmodule.
- An existing module stops with
Module [<name>] already exists!unless--forceis given. With--force, the command deletes the existing module and creates it again. - Before writing anything, the command renders every stub. A JSON stub that renders invalid JSON stops the command and leaves any existing module intact.
- If
composer.jsonuses the app folder, every class generator path must sit insidepaths.app_folder(or match its namespace whenpaths.app_folderis empty). Otherwise the command prints the offending keys and stops. - Execution order:
- Create every
paths.generatorfolder withgenerateset totrue(adding.gitkeepwhenstubs.gitkeepistrue). - Write
module.json. - Unless
plain, writestubs.files(see Configuration) and run the resource generators below. - Set the module status in the activator.
- Create every
- Resource generators (skipped for
plainmodules):module:make-seed <Name> --master(<Name>DatabaseSeeder) whenseeder.generateistrue.module:make-provider <Name>ServiceProvider --masterwhenprovider.generateistrue; otherwise removes theprovidersentry frommodule.json.module:make-event-providerandmodule:route-providerwhen theirgenerateflag istrue(a missingevent-providerkey followsprovider).module:make-controller <Name>Controllerwhencontroller.generateistrue(with--apifor API modules,--inertiafor Inertia modules).module:make-inertia-pageforIndex,Create,Show, andEditwhen--inertiais passed.
- A
plainmodule also loses the default service provider from theproviderslist ofmodule.json. - The module fires the
creatingandcreatedevents. - At the end, the command runs
composer dump-autoloadin the application root. If Composer fails, the command prints the error and exits with1. The command exits with1too when no module was created. - A stub that still holds an unreplaced
$TOKEN$after rendering prints a warning.
php artisan module:make Blog Shop --api# Modules/Blog/ and Modules/Shop/module:make-action
Section titled “module:make-action”Creates an action class in a module.
php artisan module:make-action <name> [<module>] [-i|--invokable]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Action class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--invokable |
-i |
false |
Generate a class with a single __invoke() method. |
Notes
- Writes
<Name>.phpto theactionsgenerator path (paths.generator.actions.path, defaultapp/Actions). - Stub:
action.stub, oraction-invoke.stubwith--invokable.
php artisan module:make-action CreatePost Blog# Modules/Blog/app/Actions/CreatePost.phpmodule:make-cast
Section titled “module:make-cast”Creates an Eloquent cast class in a module.
php artisan module:make-cast <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Cast class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thecastsgenerator path (paths.generator.casts.path, defaultapp/Casts). - Stub:
cast.stub.
php artisan module:make-cast Money Blog# Modules/Blog/app/Casts/Money.phpmodule:make-channel
Section titled “module:make-channel”Creates a broadcast channel class in a module.
php artisan module:make-channel <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Channel class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thechannelsgenerator path (paths.generator.channels.path, defaultapp/Broadcasting). - Stub:
channel.stub.
php artisan module:make-channel OrderChannel Blog# Modules/Blog/app/Broadcasting/OrderChannel.phpmodule:make-class
Section titled “module:make-class”Creates a class of any type in a module. The type decides the folder.
php artisan module:make-class <name> <module> [-t|--type=TYPE] [-s|--suffix] [-i|--invokable]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Class name. |
module |
yes | Module name. Required: this command does not fall back to module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--type |
-t |
class |
Type of the class, for example class, service, repository, contract. |
--suffix |
-s |
false |
Append the type to the class name. See the notes. |
--invokable |
-i |
false |
Generate a class with a single __invoke() method. |
Notes
- Stub:
class.stub, orclass-invoke.stubwith--invokable. The type is singularized. - For type
class, the file goes topaths.generator.class.path(defaultapp/Classes). For other types, the trailingClassessegment is replaced with the plural studly-case type (e.g.app/Servicesfor--type=service). Theservicesgenerator key is not read for the path. - Namespace lookup order:
paths.generator.<plural type>.namespace,paths.generator.<type>.namespace, then the computed path’s namespace. --suffixstrips any trailing singular or plural type fromname, then appends the studly-case type (MailerandMailerServicewith--type=service --suffixboth becomeMailerService).
php artisan module:make-class Mailer Blog --type=service --suffix# Modules/Blog/app/Services/MailerService.phpmodule:make-command
Section titled “module:make-command”Creates an Artisan command class in a module.
php artisan module:make-command <name> [<module>] [--command=COMMAND]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Command class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--command |
command:name |
Terminal command (signature) assigned to the class. |
Notes
- Writes
<Name>.phpto thecommandgenerator path (paths.generator.command.path, defaultapp/Console). - Stub:
command.stub.
php artisan module:make-command SendDigest Blog# Modules/Blog/app/Console/SendDigest.phpmodule:make-component
Section titled “module:make-component”Creates a Blade component class and its view in a module.
php artisan module:make-component <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Component class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thecomponent-classgenerator path (paths.generator.component-class.path, defaultapp/View/Components). - Stub:
component-class.stub. The command then runsmodule:make-component-viewwith the samename,moduleand--force. - The component name in the class is
components.<name in lower case>.
php artisan module:make-component Alert Blog# Modules/Blog/app/View/Components/Alert.phpmodule:make-component-view
Section titled “module:make-component-view”Creates a Blade component view in a module.
php artisan module:make-component-view <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Component name. The file name is the name in lower case. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<name in lower case>.blade.phpto thecomponent-viewgenerator path (paths.generator.component-view.path, defaultresources/views/components). - Stub:
component-view.stub. - The Blade comment in the view holds a random inspiring quote as plain text, like the one
module:make-viewwrites.
php artisan module:make-component-view Alert Blog# Modules/Blog/resources/views/components/alert.blade.phpmodule:make-config
Section titled “module:make-config”Creates a configuration file in a module.
php artisan module:make-config <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Config file name. The command adds .php when the name has no such ending, and keeps the case. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<name>.phpto theconfiggenerator path (paths.generator.config.path, defaultconfig). - Stub:
config.stub.
php artisan module:make-config settings Blog# Modules/Blog/config/settings.phpmodule:make-controller
Section titled “module:make-controller”Creates a controller in a module.
php artisan module:make-controller <controller> [<module>] [-p|--plain] [--api] [-i|--invokable] [--inertia]Arguments
| Name | Required | Description |
|---|---|---|
controller |
yes | Controller class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--plain |
-p |
false |
Generate a controller without methods. |
--api |
false |
Generate a resource controller without the create and edit methods. |
|
--invokable |
-i |
false |
Generate a controller with a single __invoke() method. |
--inertia |
false |
Generate an Inertia controller. |
Notes
- Writes
<Name>Controller.phpto thecontrollergenerator path (paths.generator.controller.path, defaultapp/Http/Controllers). The command appendsControllerunless the name already containscontroller, in any case. - Stub precedence (first match wins):
--plain(controller-plain.stub),--api(controller-api.stub),--invokable(controller.invokable.stub),--inertia(controller-inertia.stub), default (controller.stub).
php artisan module:make-controller PostController Blog --api# Modules/Blog/app/Http/Controllers/PostController.phpmodule:make-enum
Section titled “module:make-enum”Creates an enum in a module.
php artisan module:make-enum <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Enum name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto theenumsgenerator path (paths.generator.enums.path, defaultapp/Enums). - Stub:
enum.stub.
php artisan module:make-enum PostStatus Blog# Modules/Blog/app/Enums/PostStatus.phpmodule:make-event
Section titled “module:make-event”Creates an event class in a module.
php artisan module:make-event <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Event class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto theeventgenerator path (paths.generator.event.path, defaultapp/Events). - Stub:
event.stub.
php artisan module:make-event PostPublished Blog# Modules/Blog/app/Events/PostPublished.phpmodule:make-event-provider
Section titled “module:make-event-provider”Creates the EventServiceProvider of a module.
php artisan module:make-event-provider [<module>]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
EventServiceProvider.phpto theprovidergenerator path (paths.generator.provider.path, defaultapp/Providers). - Stub:
event-provider.stub. - The command has no
nameargument. Theevent-providergenerator key is not inconfig/config.php.module:maketreats a missing key as following theproviderentry. - The generated provider registers only the listeners in its
$listenarray. It never discovers listeners. See Listener discovery. - Overrides
configureEmailVerification()with an empty body. Without this override, each module provider would registerSendEmailVerificationNotificationonRegisteredagain, sending duplicate verification emails.
php artisan module:make-event-provider Blog# Modules/Blog/app/Providers/EventServiceProvider.phpmodule:make-exception
Section titled “module:make-exception”Creates an exception class in a module.
php artisan module:make-exception <name> [<module>] [--render] [--report]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Exception class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--render |
false |
Add an empty render() method. |
|
--report |
false |
Add an empty report() method. |
Notes
- Writes
<Name>.phpto theexceptionsgenerator path (paths.generator.exceptions.path, defaultapp/Exceptions). - Stub:
exception.stub,exception-render.stub(--render),exception-report.stub(--report) orexception-render-report.stub(both).
php artisan module:make-exception PostNotFound Blog# Modules/Blog/app/Exceptions/PostNotFound.phpmodule:make-factory
Section titled “module:make-factory”Creates a model factory in a module.
php artisan module:make-factory <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Model name. The command appends Factory. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>Factory.phpto thefactorygenerator path (paths.generator.factory.path, defaultdatabase/factories). - Stub:
factory.stub. The model namespace comes from themodelgenerator path.
php artisan module:make-factory Post Blog# Modules/Blog/database/factories/PostFactory.phpmodule:make-helper
Section titled “module:make-helper”Creates a helper class in a module.
php artisan module:make-helper <name> [<module>] [-i|--invokable]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Helper class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--invokable |
-i |
false |
Generate a class with a single __invoke() method. |
Notes
- Writes
<Name>.phpto thehelpersgenerator path (paths.generator.helpers.path, defaultapp/Helpers). - Stub:
helper.stub, orhelper-invoke.stubwith--invokable.
php artisan module:make-helper Str Blog# Modules/Blog/app/Helpers/Str.phpmodule:make-health-indicator
Section titled “module:make-health-indicator”Creates a health indicator class for nwidart/laravel-actuator in a module.
php artisan module:make-health-indicator <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Health indicator class name. The command adds no suffix. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phptopaths.generator.health.pathwhen set, otherwise<paths.app_folder>Health(defaultapp/Health, namespaceModules\<Module>\Health). See Configuration. - Each segment of a nested name is converted to StudlyCase, for the folder and for the namespace:
api/v2/Paymentsgivesapp/Health/Api/V2/Payments.phpin the namespaceModules\Blog\Health\Api\V2. - Stub:
health-indicator.stub. - The command works without the actuator installed, but the generated class needs the actuator to be used.
- The command does not edit the module service provider. It prints the line to add to the
$healthIndicatorsproperty. The suggested key is the class name without a trailingHealthIndicator, in camel case. See Report module health with the actuator.
php artisan module:make-health-indicator PaymentsHealthIndicator Blog# Modules/Blog/app/Health/PaymentsHealthIndicator.php## INFO Register it as [module:blog:payments] in the $healthIndicators property of the module service provider:# 'payments' => \Modules\Blog\Health\PaymentsHealthIndicator::class,module:make-inertia-component
Section titled “module:make-inertia-component”Creates an Inertia component in a module.
php artisan module:make-inertia-component <name> [<module>] [--vue] [--react] [--svelte]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Inertia component name. A name with / or \ creates sub-directories under the component folder. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--vue |
false |
Create a Vue file. | |
--react |
false |
Create a React file. | |
--svelte |
false |
Create a Svelte file. |
Notes
- Writes
<Name>.vue,<Name>.jsxor<Name>.svelteto theinertia-componentsgenerator path (paths.generator.inertia-components.path, defaultresources/js/Components). - Stub:
inertia/component-vue.stub,inertia/component-react.stuborinertia/component-svelte.stub. - Framework comes from the flag given, else
inertia.frontend(defaultvue). Passing more than one of--vue,--react, and--sveltewrites nothing, exits with1, and prints an error (for exampleThe --react and --svelte options cannot be used together. Pass only one of --vue, --react or --svelte.).
php artisan module:make-inertia-component Posts/Index Blog --react# Modules/Blog/resources/js/Components/Posts/Index.jsxmodule:make-inertia-page
Section titled “module:make-inertia-page”Creates an Inertia page in a module.
php artisan module:make-inertia-page <name> [<module>] [--vue] [--react] [--svelte]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Inertia page name. A name with / or \ creates sub-directories under the page folder. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--vue |
false |
Create a Vue file. | |
--react |
false |
Create a React file. | |
--svelte |
false |
Create a Svelte file. |
Notes
- Writes
<Name>.vue,<Name>.jsxor<Name>.svelteto theinertiagenerator path (paths.generator.inertia.path, defaultresources/js/Pages). - Stub:
inertia/page-vue.stub,inertia/page-react.stuborinertia/page-svelte.stub. - Framework comes from the flag given, else
inertia.frontend(defaultvue). Passing more than one of--vue,--react, and--sveltewrites nothing, exits with1, and prints an error (for exampleThe --react and --svelte options cannot be used together. Pass only one of --vue, --react or --svelte.).
php artisan module:make-inertia-page Posts/Index Blog --react# Modules/Blog/resources/js/Pages/Posts/Index.jsxmodule:make-interface
Section titled “module:make-interface”Creates an interface in a module.
php artisan module:make-interface <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Interface name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto theinterfacesgenerator path (paths.generator.interfaces.path, defaultapp/Interfaces). - Stub:
interface.stub.
php artisan module:make-interface PostRepository Blog# Modules/Blog/app/Interfaces/PostRepository.phpmodule:make-job
Section titled “module:make-job”Creates a queued job class in a module.
php artisan module:make-job <name> [<module>] [--sync]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Job class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--sync |
false |
Generate a synchronous job. |
Notes
- Writes
<Name>.phpto thejobsgenerator path (paths.generator.jobs.path, defaultapp/Jobs). - Stub:
job-queued.stub, orjob.stubwith--sync.
php artisan module:make-job PublishPost Blog# Modules/Blog/app/Jobs/PublishPost.phpmodule:make-job-middleware
Section titled “module:make-job-middleware”Creates a job middleware class in a module.
php artisan module:make-job-middleware <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Job middleware class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thejob-middlewaregenerator path (paths.generator.job-middleware.path, defaultapp/Jobs/Middleware). - Stub:
job-middleware.stub. - When
paths.generator.job-middlewarehas no path, the file goes to aMiddlewarefolder inside thejobsgenerator path.
php artisan module:make-job-middleware RateLimited Blog# Modules/Blog/app/Jobs/Middleware/RateLimited.phpmodule:make-listener
Section titled “module:make-listener”Creates an event listener in a module.
php artisan module:make-listener <name> [<module>] [-e|--event=EVENT] [--queued]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Listener class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--event |
-e |
none | Event class the listener handles. |
--queued |
false |
Generate a queued listener. |
Notes
- Writes
<Name>.phpto thelistenergenerator path (paths.generator.listener.path, defaultapp/Listeners). - Stub:
listener.stubwith--event, orlistener-duck.stubwithout it (untyped$event). With--queued:listener-queued.stuborlistener-queued-duck.stub. - An event starting with
\, the application namespace,Illuminate\, or the modules namespace is used as a fully qualified class name. Other values resolve to<modules namespace>\<Module>\<event namespace>\<event>.
php artisan module:make-listener SendNotification Blog --event=PostPublished --queued# Modules/Blog/app/Listeners/SendNotification.phpListener discovery
Section titled “Listener discovery”Laravel discovers listeners only in app/Listeners by default; Modules/<Name>/app/Listeners is not added automatically. Module listeners are registered either via $listen on the module EventServiceProvider or by adding module listener paths to Laravel event discovery (bootstrap/app.php withEvents(discover: ...) or EventServiceProvider::addEventDiscoveryPaths()).
LaravelModulesServiceProviderregistersNwidart\Modules\Support\ListenerClassNameGuesserso discovered files underModules/<Name>/app/Listeners/resolve toModules\<Name>\Listeners\....- Glob discovery paths match disabled modules too.
- When using
php artisan event:cache, re-cache after enabling or disabling a module. - Listing a discovered listener in
$listenregisters it twice.
For setup steps, see Register events and listeners.
module:make-mail
Section titled “module:make-mail”Creates a mailable class in a module.
php artisan module:make-mail <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Mailable class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto theemailsgenerator path (paths.generator.emails.path, defaultapp/Emails). - Stub:
mail.stub.
php artisan module:make-mail WelcomeMail Blog# Modules/Blog/app/Emails/WelcomeMail.phpmodule:make-middleware
Section titled “module:make-middleware”Creates a middleware class in a module.
php artisan module:make-middleware <name> [<module>] [--inertia]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Middleware class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--inertia |
false |
Generate an Inertia HandleInertiaRequests middleware. |
Notes
- Writes
<Name>.phpto thefiltergenerator path (paths.generator.filter.path, defaultapp/Http/Middleware). - Stub:
middleware.stub, ormiddleware/handle-inertia-requests.stubwith--inertia.
php artisan module:make-middleware EnsureIsAdmin Blog# Modules/Blog/app/Http/Middleware/EnsureIsAdmin.phpmodule:make-migration
Section titled “module:make-migration”Creates a migration in a module.
php artisan module:make-migration <name> [<module>] [--fields=FIELDS] [--plain]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Migration name, in snake case, for example create_posts_table. The command uses it as given. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--fields |
none | Columns, comma-separated, for example title:string, body:text. Ignored with --plain. |
|
--plain |
false |
Use migration/plain.stub (empty up() and down()) whatever the name is. |
Notes
- Writes
<Y_m_d_His>_<name>.phpto themigrationgenerator path (paths.generator.migration.path, defaultdatabase/migrations). All five shipped stubs generate anonymous classes (return new class extends Migration); the studly-case name is still passed as$CLASS$for custom stubs. - Stub selection:
--plainalways usesmigration/plain.stub. Otherwise the first word ofnameselects the stub:create,make->migration/create.stubadd,update,append,insert->migration/add.stubdelete,remove->migration/delete.stubdestroy,drop->migration/drop.stub- any other word ->
migration/plain.stub
- The table name comes from the rest of the name:
create_posts_tablegivesposts,add_slug_to_posts_tablegivesposts. - The generated column lines are indented with four spaces per level (12 spaces inside
Schema::create), without tab characters or a blank line before});. - Each field is
column:type[:modifier...]. The shortcutssoft_deleteandremember_token, andbelongsTo:column:key:table, are also accepted.
php artisan module:make-migration create_posts_table Blog --fields="title:string, body:text"# Modules/Blog/database/migrations/2026_01_01_000000_create_posts_table.phpmodule:make-model
Section titled “module:make-model”Creates an Eloquent model in a module, and optionally the files that go with it.
php artisan module:make-model <model> [<module>] [-a|--all] [--attributes] [-c|--controller] [--fillable=FILLABLE] [-f|--factory] [-m|--migration] [-r|--request] [-R|--resource] [-p|--policy] [-s|--seed] [--force]Arguments
| Name | Required | Description |
|---|---|---|
model |
yes | Model class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--all |
-a |
false |
Same as -c -f -m -r -R -p -s. |
--attributes |
false |
Use Eloquent attributes such as #[Fillable] instead of model properties. |
|
--controller |
-c |
false |
Also run module:make-controller <Model>Controller. |
--fillable |
none | Comma-separated fillable attributes. | |
--factory |
-f |
false |
Also run module:make-factory <Model>, and add the factory to the model. |
--migration |
-m |
false |
Also run module:make-migration create_<plural snake name>_table. |
--request |
-r |
false |
Also run module:make-request <Model>Request. |
--resource |
-R |
false |
Also run module:make-resource <Model>Resource. |
--policy |
-p |
false |
Also run module:make-policy <Model>Policy. |
--seed |
-s |
false |
Also run module:make-seed <Model>Seeder. |
--force |
false |
Overwrite the model when it exists. No shortcut: -f is --factory. |
Notes
- Writes
<Model>.phpto themodelgenerator path (paths.generator.model.path, defaultapp/Models). - Stub:
model.stub, with the sectionsATTRIBUTES,FACTORYandPROPERTIES. - The related commands run after the model is written, and only when the model was written. They receive no
--force. A migration name forBlogPostiscreate_blog_posts_table. - The command runs every related command it was asked for. It exits with
1when one of them fails, for example when the migration or controller file already exists. --fillable=title,bodywrites['title','body']to the model.
php artisan module:make-model Post Blog -mfc# Modules/Blog/app/Models/Post.php, plus a migration, a factory and a controllermodule:make-notification
Section titled “module:make-notification”Creates a notification class in a module.
php artisan module:make-notification <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Notification class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thenotificationsgenerator path (paths.generator.notifications.path, defaultapp/Notifications). - Stub:
notification.stub.
php artisan module:make-notification PostPublished Blog# Modules/Blog/app/Notifications/PostPublished.phpmodule:make-observer
Section titled “module:make-observer”Creates a model observer in a module.
php artisan module:make-observer <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Model name. The command appends Observer. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>Observer.phpto theobservergenerator path (paths.generator.observer.path, defaultapp/Observers). - Stub:
observer.stub. The model namespace comes from themodelgenerator path.
php artisan module:make-observer Post Blog# Modules/Blog/app/Observers/PostObserver.phpmodule:make-policy
Section titled “module:make-policy”Creates a policy class in a module.
php artisan module:make-policy <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Policy class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thepoliciesgenerator path (paths.generator.policies.path, defaultapp/Policies). - Stub:
policy.plain.stub.
php artisan module:make-policy PostPolicy Blog# Modules/Blog/app/Policies/PostPolicy.phpmodule:make-provider
Section titled “module:make-provider”Creates a service provider in a module.
php artisan module:make-provider <name> [<module>] [--master]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Service provider class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--master |
false |
Generate the main provider of the module, which registers the other providers. |
Notes
- Writes
<Name>.phpto theprovidergenerator path (paths.generator.provider.path, defaultapp/Providers). - Stub:
provider.stub, orscaffold/provider.stubwith--master.
php artisan module:make-provider BlogServiceProvider Blog# Modules/Blog/app/Providers/BlogServiceProvider.phpmodule:make-replacement
Section titled “module:make-replacement”Creates a replacement key class for stubs in a module.
php artisan module:make-replacement <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Replacement class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thecommand_replacementsgenerator path (paths.generator.command_replacements.path, defaultapp/Console/Replacements). - Stub:
replacement.stub. - The generated class extends
Nwidart\Modules\Support\ReplacementKeyCommand. Itshandle()body returnsstrtolower($this->generator->getName()), the lower-case module name. See Generating a class.
php artisan module:make-replacement AppUrl Blog# Modules/Blog/app/Console/Replacements/AppUrl.phpmodule:make-repository
Section titled “module:make-repository”Creates a repository class in a module.
php artisan module:make-repository <name> [<module>] [-i|--invokable]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Repository class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--invokable |
-i |
false |
Generate a class with a single __invoke() method. |
Notes
- Writes
<Name>.phpto therepositorygenerator path (paths.generator.repository.path, defaultapp/Repositories). - Stub:
repository.stub, orrepository-invoke.stubwith--invokable.
php artisan module:make-repository PostRepository Blog# Modules/Blog/app/Repositories/PostRepository.phpmodule:make-request
Section titled “module:make-request”Creates a form request class in a module.
php artisan module:make-request <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Form request class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto therequestgenerator path (paths.generator.request.path, defaultapp/Http/Requests). - Stub:
request.stub.
php artisan module:make-request StorePostRequest Blog# Modules/Blog/app/Http/Requests/StorePostRequest.phpmodule:make-resource
Section titled “module:make-resource”Creates an API resource class in a module.
php artisan module:make-resource <name> [<module>] [-c|--collection] [-j|--json-api]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Resource class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--collection |
-c |
false |
Generate a resource collection. |
--json-api |
-j |
false |
Generate a JSON:API resource. |
Notes
- Writes
<Name>.phpto theresourcegenerator path (paths.generator.resource.path, defaultapp/Transformers). - Stub:
resource-collection.stubfor--collectionor a name that ends withCollection, elseresource-json-api.stubfor--json-api, elseresource.stub.
php artisan module:make-resource PostResource Blog# Modules/Blog/app/Transformers/PostResource.phpmodule:make-rule
Section titled “module:make-rule”Creates a validation rule in a module.
php artisan module:make-rule <name> [<module>] [-i|--implicit]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Rule class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--implicit |
-i |
false |
Generate an implicit rule. |
Notes
- Writes
<Name>.phpto therulesgenerator path (paths.generator.rules.path, defaultapp/Rules). - Stub:
rule.stub, orrule.implicit.stubwith--implicit.
php artisan module:make-rule Uppercase Blog# Modules/Blog/app/Rules/Uppercase.phpmodule:make-scope
Section titled “module:make-scope”Creates an Eloquent scope class in a module.
php artisan module:make-scope <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Scope class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thescopesgenerator path (paths.generator.scopes.path, defaultapp/Models/Scopes). - Stub:
scope.stub. - When
paths.generator.scopeshas no path, the file goes to aScopesfolder inside themodelgenerator path.
php artisan module:make-scope PublishedScope Blog# Modules/Blog/app/Models/Scopes/PublishedScope.phpmodule:make-seed
Section titled “module:make-seed”Creates a database seeder in a module.
php artisan module:make-seed <name> [<module>] [--master]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Seeder name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--master |
false |
Generate the main seeder of the module (<Name>DatabaseSeeder). |
Notes
- Writes
<Name>Seeder.phpto theseedergenerator path (paths.generator.seeder.path, defaultdatabase/seeders). - Stub:
seeder.stub. - The command appends
Seederunless the name already containsSeeder. With--masterit appendsDatabasefirst. - A name that resolves to the class
Seederis rejected: it clashes with theIlluminate\Database\Seederbase class. - The command clears the module cache before it writes.
php artisan module:make-seed Post Blog# Modules/Blog/database/seeders/PostSeeder.phpmodule:make-service
Section titled “module:make-service”Creates a service class in a module.
php artisan module:make-service <name> [<module>] [-i|--invokable]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Service class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--invokable |
-i |
false |
Generate a class with a single __invoke() method. |
Notes
- Writes
<Name>.phpto theservicesgenerator path (paths.generator.services.path, defaultapp/Services). - Stub:
service.stub, orservice-invoke.stubwith--invokable.
php artisan module:make-service PostPublisher Blog# Modules/Blog/app/Services/PostPublisher.phpmodule:make-test
Section titled “module:make-test”Creates a test class in a module.
php artisan module:make-test <name> [<module>] [--feature]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Test class name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--feature |
false |
Create a feature test instead of a unit test. |
Notes
- Writes
<Name>.phpto thetest-unitgenerator path (paths.generator.test-unit.path, defaulttests/Unit), or to thetest-featurepath (paths.generator.test-feature.path, defaulttests/Feature) with--feature. - Stub:
tests/unit.stub, ortests/feature.stubwith--feature. - Namespace: the module namespace plus the generator path, without the app folder. With the default paths,
Modules\Blog\Tests\UnitorModules\Blog\Tests\Feature. Withpaths.app_folderset toapp/and a test path ofapp/Tests/Unit, the namespace isModules\Blog\Tests\Unit.
php artisan module:make-test PostTest Blog --feature# Modules/Blog/tests/Feature/PostTest.phpmodule:make-trait
Section titled “module:make-trait”Creates a trait in a module.
php artisan module:make-trait <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | Trait name. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<Name>.phpto thetraitsgenerator path (paths.generator.traits.path, defaultapp/Traits). - Stub:
trait.stub.
php artisan module:make-trait HasSlug Blog# Modules/Blog/app/Traits/HasSlug.phpmodule:make-view
Section titled “module:make-view”Creates a Blade view in a module.
php artisan module:make-view <name> [<module>]Arguments
| Name | Required | Description |
|---|---|---|
name |
yes | View name. The file name is the name in lower case. |
module |
no | Module name. Falls back to the module set by module:use. |
Options
This command has no options besides --force.
Notes
- Writes
<name in lower case>.blade.phpto theviewsgenerator path (paths.generator.views.path, defaultresources/views). - Stub:
view.stub.
php artisan module:make-view index Blog# Modules/Blog/resources/views/index.blade.phpmodule:route-provider
Section titled “module:route-provider”Creates the RouteServiceProvider of a module.
php artisan module:route-provider [<module>] [--force]Arguments
| Name | Required | Description |
|---|---|---|
module |
no | Module name. Falls back to the module set by module:use. |
Options
| Name | Shortcut | Default | Description |
|---|---|---|---|
--force |
false |
Overwrite the file when it exists. No shortcut. |
Notes
- The command name has no
make-prefix and the command has nonameargument. - Writes
RouteServiceProvider.phpto theprovidergenerator path (paths.generator.provider.path, defaultapp/Providers). - Stub:
route-provider.stub. WEB_ROUTESandAPI_ROUTESstay only whenroutes.generateistrueandstubs.fileslistsroutes/weborroutes/api.
php artisan module:route-provider Blog# Modules/Blog/app/Providers/RouteServiceProvider.php