Blog Detail


 Handle Domain Driven Design Projects with Diamond Console cover image

arrow_back Handle Domain Driven Design Projects with Diamond Console

Diamond Console is an Artisan command package to handle your Domain Driven Design project that is suitable with Laravel base structures, made for comer of Domain Driven Design and advanced.


Install Diamond Console with composer

composer require koalafacade/diamond-console

then after Diamond Console is installed run the command below to set up your project. The command below will generate a namespace in composer and base directory structures.

 php artisan diamond:install


domain:make:action GenerateProfileAction User

Command for generating an Action inside your Domain directory.

domain:make:enum Role User

Command for generate an Enum to your Domain directory.

domain:make:data-transfer-object RoleData User

Command for generate a Data Transfer Object with plain PHP to your domain directory.

application:migration create_user_table

Command for generate a Migration file

domain:make:model User User

Command for generate a Model inside Shared in Domain directory, all Model will store shared folder since another Domain probably consume the Model at the same time.

infrastructure:make:factory RoleFactory User

Command for generate a Factory class, this command would generate two files :

  • Factory concrete at Infrastructure/{DomainName}/Database/Factories
  • Factory Contract at Domain/Shared/Contracts/Database/Factories

The bottom reason why we did this, is cause Factories is an Infrastructure component then Domain can’t consume any stuff inside Infrastructure, so you can do Dependency Injection at Service Provider to resolve this one.

infrastructure:make:observer UserObserver User

Command for generate a Observer class to your project.

infrastructure:make:event PostEvent Post

Command for generate a Event class to your project.

infrastructure:make:listener PostListener Post

Command for generate a Listener class to your project.

For more details, please visit Github.

Published at : 15-12-2022

Author : Rizwan Aslam
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch your project

Launch project