Useful Tip:
You can use the following commands with the --help
suffix to find its arguments and options.
You can use the following commands with the --help
suffix to find its arguments and options.
Note all the following commands use "Blog" as example module name, and example class/file names
Generate a new module.
php artisan module:make Blog
Generate multiple modules at once.
php artisan module:make Blog User Auth
Use a given module. This allows you to not specify the module name on other commands requiring the module name as an argument.
php artisan module:use Blog
This unsets the specified module that was set with the module:use
command.
php artisan module:unuse
List all available modules.
php artisan module:list
Migrate the given module, or without a module an argument, migrate all modules.
php artisan module:migrate Blog
Rollback the given module, or without an argument, rollback all modules.
php artisan module:migrate-rollback Blog
Refresh the migration for the given module, or without a specified module refresh all modules migrations.
php artisan module:migrate-refresh Blog
Reset the migration for the given module, or without a specified module reset all modules migrations.
php artisan module:migrate-reset Blog
Seed the given module, or without an argument, seed all modules
php artisan module:seed Blog
Publish the migration files for the given module, or without an argument publish all modules migrations.
php artisan module:publish-migration Blog
Publish the given module configuration files, or without an argument publish all modules configuration files.
php artisan module:publish-config Blog
Publish the translation files for the given module, or without a specified module publish all modules migrations.
php artisan module:publish-translation Blog
Enable the given module.
php artisan module:enable Blog
Disable the given module.
php artisan module:disable Blog
Update the given module.
php artisan module:update Blog
Generate the given console command for the specified module.
php artisan module:make-command CreatePostCommand Blog
Generate a migration for specified module.
php artisan module:make-migration create_posts_table Blog
Generate the given seed name for the specified module.
php artisan module:make-seed seed_fake_blog_posts Blog
Generate a controller for the specified module.
php artisan module:make-controller PostsController Blog
Generate the given model for the specified module.
php artisan module:make-model Post Blog
Optional options:
--fillable=field1,field2
: set the fillable fields on the generated model--migration
, -m
: create the migration file for the given modelGenerate the given service provider name for the specified module.
php artisan module:make-provider BlogServiceProvider Blog
Generate the given middleware name for the specified module.
php artisan module:make-middleware CanReadPostsMiddleware Blog
Generate the given mail class for the specified module.
php artisan module:make-mail SendWeeklyPostsEmail Blog
Generate the given notification class name for the specified module.
php artisan module:make-notification NotifyAdminOfNewComment Blog
Generate the given listener for the specified module. Optionally you can specify which event class it should listen to. It also accepts a --queued
flag allowed queued event listeners.
php artisan module:make-listener NotifyUsersOfANewPost Blog
php artisan module:make-listener NotifyUsersOfANewPost Blog --event=PostWasCreated
php artisan module:make-listener NotifyUsersOfANewPost Blog --event=PostWasCreated --queued
Generate the given request for the specified module.
php artisan module:make-request CreatePostRequest Blog
Generate the given event for the specified module.
php artisan module:make-event BlogPostWasUpdated Blog
Generate the given job for the specified module.
php artisan module:make-job JobName Blog
php artisan module:make-job JobName Blog --sync # A synchronous job class
Generate the given route service provider for the specified module.
php artisan module:route-provider Blog
Generate the given database factory for the specified module.
php artisan module:make-factory FactoryName Blog
Generate the given policy class for the specified module.
The Policies
is not generated by default when creating a new module. Change the value of paths.generator.policies
in modules.php
to your desired location.
php artisan module:make-policy PolicyName Blog
Generate the given validation rule class for the specified module.
The Rules
folder is not generated by default when creating a new module. Change the value of paths.generator.rules
in modules.php
to your desired location.
php artisan module:make-rule ValidationRule Blog
Generate the given resource class for the specified module. It can have an optional --collection
argument to generate a resource collection.
The Transformers
folder is not generated by default when creating a new module. Change the value of paths.generator.resource
in modules.php
to your desired location.
php artisan module:make-resource PostResource Blog
php artisan module:make-resource PostResource Blog --collection
Generate the given test class for the specified module.
php artisan module:make-test EloquentPostRepositoryTest Blog
php artisan module:make-test EloquentPostRepositoryTest Blog --feature