Module Console Commands

Edit on

A module may contain custom console commands. You can generate these commands manually, or with the following artisan command:

php artisan module:make-command CreatePostCommand Blog

This will create a command called CreatePostCommand inside the Blog module. By default, this will be in the path: Modules/Blog/Console/CreatePostCommand.

Registering The Command

You cna register the command with the laravel method commands which is available inside a service provider class.

// In your boot or register method in the service provider:

public function boot()
{
    if ($this->app->runningInConsole()) {
        $this->commands([
            \Modules\Blog\Console\CreatePostCommand::class,
        ]);
    }
}

You can now access your command via php artisan in the console.

For more information on artisan commands, please refer to the documentation.