Skip to content

Commands

Sevan Nerse edited this page May 19, 2021 · 5 revisions

Tip: You can use the following commands with the --help suffix to find its arguments and options.

Utility

module:make

Generate a new module.

php artisan module:make my-blog

module:make

Generate multiple modules at once.

php artisan module:make my-blog projects crm

module:use

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 my-blog

module:unuse

This unsets the specified module that was set with the module:use command.

php artisan module:unuse

module:list

List all available modules.

php artisan module:list

module:migrate

Migrate the given module, or without a module an argument, migrate all modules.

php artisan module:migrate my-blog

module:migrate-rollback

Rollback the given module, or without an argument, rollback all modules.

php artisan module:migrate-rollback my-blog

module:migrate-refresh

Refresh the migration for the given module, or without a specified module refresh all modules migrations.

php artisan module:migrate-refresh my-blog

module:migrate-reset my-blog

Reset the migration for the given module, or without a specified module reset all modules migrations.

php artisan module:migrate-reset my-blog

module:seed

Seed the given module, or without an argument, seed all modules

php artisan module:seed my-blog

module:publish-migration

Publish the migration files for the given module, or without an argument publish all modules migrations.

php artisan module:publish-migration my-blog

module:publish-config

Publish the given module configuration files, or without an argument publish all modules configuration files.

php artisan module:publish-config my-blog

module:publish-translation

Publish the translation files for the given module, or without a specified module publish all modules migrations.

php artisan module:publish-translation my-blog

module:enable

Enable the given module.

php artisan module:enable my-blog

module:disable

Disable the given module.

php artisan module:disable my-blog

module:update

Update the given module.

php artisan module:update my-blog

Generator

module:make-command

Generate the given console command for the specified module.

php artisan module:make-command CreatePostCommand my-blog

module:make-migration

Generate a migration for specified module.

php artisan module:make-migration create_posts_table my-blog

module:make-seed

Generate the given seed name for the specified module.

php artisan module:make-seed seed_fake_blog_posts my-blog

module:make-controller

Generate a controller for the specified module.

php artisan module:make-controller Posts my-blog

module:make-model

Generate the given model for the specified module.

php artisan module:make-model Post my-blog

Optional options:

  • --fillable=field1,field2: set the fillable fields on the generated model
  • --migration, -m: create the migration file for the given model
  • --factory, -f: create the factory file for the given model

module:make-provider

Generate the given service provider name for the specified module.

php artisan module:make-provider Event my-blog

module:make-middleware

Generate the given middleware name for the specified module.

php artisan module:make-middleware CanReadPostsMiddleware my-blog

module:make-mail

Generate the given mail class for the specified module.

php artisan module:make-mail SendWeeklyPostsEmail my-blog

module:make-notification

Generate the given notification class name for the specified module.

php artisan module:make-notification NotifyAdminOfNewComment my-blog

module:make-listener

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 my-blog
php artisan module:make-listener NotifyUsersOfANewPost my-blog --event=PostWasCreated
php artisan module:make-listener NotifyUsersOfANewPost my-blog --event=PostWasCreated --queued

module:make-request

Generate the given request for the specified module.

php artisan module:make-request CreatePostRequest my-blog

module:make-event

Generate the given event for the specified module.

php artisan module:make-event BlogPostWasUpdated my-blog

module:make-job

Generate the given job for the specified module.

php artisan module:make-job JobName my-blog

php artisan module:make-job JobName my-blog --sync # A synchronous job class

module:make-factory

Generate the given database factory for the specified module.

php artisan module:make-factory FactoryName my-blog

module:make-policy

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.policy in config/module.php to your desired location.

php artisan module:make-policy PolicyName my-blog

module:make-rule

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 config/module.php to your desired location.

php artisan module:make-rule ValidationRule my-blog

module:make-resource

Generate the given API resource class for the specified module. It can have an optional --collection argument to generate a resource collection.

The Http/Resources folder is not generated by default when creating a new module. Change the value of paths.generator.resource in config/module.php to your desired location.

php artisan module:make-resource PostResource my-blog
php artisan module:make-resource PostResource my-blog --collection

module:make-test

Generate the given test class for the specified module.

php artisan module:make-test EloquentPostRepositoryTest my-blog

module:make-component

Generate the given view component for the specified module.

php artisan module:make-component MyAlert my-blog

module:make-cast

Generate the given cast class for the specified module.

The Casts is not generated by default when creating a new module. Change the value of paths.generator.cast in config/module.php to your desired location.

php artisan module:make-cast CastName my-blog

module:make-observer

Generate the given observer class for the specified module.

The Observers is not generated by default when creating a new module. Change the value of paths.generator.observer in config/module.php to your desired location.

php artisan module:make-observer ObserverName my-blog
php artisan module:make-observer ObserverName my-blog --model=Post

Optional options:

  • --model, -m: create the observer file for the given model

module:make-exception

Generate the given exception class for the specified module.

The Exceptions is not generated by default when creating a new module. Change the value of paths.generator.exception in config/module.php to your desired location.

php artisan module:make-exception ExceptionName my-blog