Laravel custom command line package isn't running

1 day ago 1
ARTICLE AD BOX

Laravel Custom Composer Package Command Not Registering (make:ddd)

I created a custom Laravel package to generate a DDD-style CRUD structure. The package installs successfully via Composer, but the Artisan command is not recognized.

When I run:

php artisan make:ddd Post

I get:

Command "make:ddd" is not defined.

The package appears to install correctly, but Laravel does not register the command.


Package Structure

dddcrudgenerator/ ├── src/ │ ├── Commands/ │ │ └── MakeDDDCRUDCommand.php │ └── DDDCRUDGeneratorServiceProvider.php ├── stubs/ └── composer.json

Service Provider

namespace Rahamat\DDDCRUDGenerator; use Illuminate\Support\ServiceProvider; use Rahamat\DDDCRUDGenerator\Commands\MakeDDDCRUDCommand; class DDDCRUDGeneratorServiceProvider extends ServiceProvider { public function register() { } public function boot() { if ($this->app->runningInConsole()) { $this->commands([ MakeDDDCRUDCommand::class ]); } } }

Artisan Command

namespace Rahamat\DDDCRUDGenerator\Commands; use Illuminate\Console\Command; class MakeDDDCRUDCommand extends Command { protected $signature = 'make:ddd {name}'; protected $description = 'Generate simple CRUD (Model, Migration, Controller, Route)'; public function handle() { $name = $this->argument('name'); $this->info("Generating CRUD for: " . $name); } }

composer.json

{ "name": "rahamatj/dddcrudgenerator", "description": "DDD CRUD generator", "type": "library", "license": "MIT", "autoload": { "psr-4": { "Rahamat\\DDDCRUDgenerator\\": "src/" } }, "authors": [ { "name": "Rahamat Jahan" } ], "minimum-stability": "stable", "require": {}, "extra": { "laravel": { "providers": [ "Rahamat\\DDDCRUDgenerator\\DDDCRUDgeneratorServiceProvider" ] } } }

What I've Tried

Installed the package via Composer

Ran:

composer dump-autoload php artisan cache:clear php artisan config:clear Verified the package appears in vendor/

However, the make:ddd command still does not show up when running:

php artisan list

Question

What could cause a Laravel package command not to register even though the service provider and command class appear to be correctly defined?

Is there something wrong with my namespace, PSR-4 autoload configuration, or service provider registration?

Read Entire Article