# Commands

**Package:** Laravel Modules | **Version:** 3 | **URL:** https://mozex.dev/docs/laravel-modules/v3/features/commands

---

## Overview

Discovers module Artisan command classes and registers them automatically. Any non-abstract class extending `Illuminate\Console\Command` that matches configured patterns is added to Artisan.

## Default configuration

```php
'commands' => [
    'active' => true,
    'patterns' => [
        '*/Console/Commands',
    ],
],
```

## Directory layout

```
Modules/Blog/
└── Console/
    └── Commands/
        ├── PublishPosts.php          // extends Command (discovered)
        └── BaseCommand.php           // abstract (ignored)
```

## Usage

Commands are available via Artisan as soon as they are discovered:

```bash
php artisan blog:publish-posts
```

## Console routes

If you define module `Routes/console.php` files and your Laravel version supports command route paths (Laravel 10+), those commands are also registered. See [Routes](https://mozex.dev/docs/laravel-modules/v3/features/routes).

## Configuration

- Set `'commands.active' => false` to disable auto-registration.
- Edit `'commands.patterns'` to change discovery directories.

## Troubleshooting

- **Command not found**: ensure it extends `Illuminate\Console\Command`, has a `$signature`, and is under a discovered path.
- **Duplicate signature**: ensure unique `$signature` values across modules.

---

## Table of Contents

- [Introduction](https://mozex.dev/docs/laravel-modules/v3)
- [Support Us](https://mozex.dev/docs/laravel-modules/v3/support-us)
- [Requirements](https://mozex.dev/docs/laravel-modules/v3/requirements)
- [Changelog](https://mozex.dev/docs/laravel-modules/v3/changelog)
- [Contributing](https://mozex.dev/docs/laravel-modules/v3/contributing)
- [Questions & Issues](https://mozex.dev/docs/laravel-modules/v3/questions-and-issues)
- [About Mozex](https://mozex.dev/docs/laravel-modules/v3/about)

### Features

- [Blade Components](https://mozex.dev/docs/laravel-modules/v3/features/blade-components)
- [Views](https://mozex.dev/docs/laravel-modules/v3/features/views)
- [Routes](https://mozex.dev/docs/laravel-modules/v3/features/routes)
- [Configs](https://mozex.dev/docs/laravel-modules/v3/features/configs)
- [Migrations](https://mozex.dev/docs/laravel-modules/v3/features/migrations)
- [Seeders](https://mozex.dev/docs/laravel-modules/v3/features/seeders)
- [Commands](https://mozex.dev/docs/laravel-modules/v3/features/commands)
- [Helpers](https://mozex.dev/docs/laravel-modules/v3/features/helpers)
- [Models & Factories](https://mozex.dev/docs/laravel-modules/v3/features/models-factories)
- [Policies](https://mozex.dev/docs/laravel-modules/v3/features/policies)
- [Events & Listeners](https://mozex.dev/docs/laravel-modules/v3/features/events-listeners)
- [Service Providers](https://mozex.dev/docs/laravel-modules/v3/features/service-providers)
- [Translations](https://mozex.dev/docs/laravel-modules/v3/features/translations)
- [Caching](https://mozex.dev/docs/laravel-modules/v3/features/caching)
- [Listing Modules](https://mozex.dev/docs/laravel-modules/v3/features/listing)
- [Livewire Components](https://mozex.dev/docs/laravel-modules/v3/features/livewire-components)
- [Filament](https://mozex.dev/docs/laravel-modules/v3/features/filament)
- [Nova Resources](https://mozex.dev/docs/laravel-modules/v3/features/nova-resources)

### Integrations

- [PHPStan](https://mozex.dev/docs/laravel-modules/v3/integrations/phpstan)
- [PHPUnit](https://mozex.dev/docs/laravel-modules/v3/integrations/phpunit)
- [Pest](https://mozex.dev/docs/laravel-modules/v3/integrations/pest)