Skip to main content
  1. Packages/
  2. Diamond Console/

Infrastructure

3 mins·

Introduction #

Infrastructure Layer in Domain Driven Design is a layer that contains external services such as Database, Messaging System, and Email Services etc. So mainly this layer contains the whole external services logic.

Commands #

The list of commands that can you use for structuring your Domain Driven Design project.

Event #

Command for generate an Event class to your project.

Command #

php artisan infrastructure:make:event PostEvent Post

Arguments #

NameDescription
NameEvent name class
DomainDomain Name

Options #

NameDescription
--forceForce create the Event class

Factory #

Command for generate a Factory class.

This command would generate two files :

  1. Factory Concrete at Infrastructure/{DomainName}/Database/Factories
  2. Factory Contract at Domain/Shared/Contracts/Database/Factories

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

Command #

php artisan infrastructure:make:factory RoleFactory User

Arguments #

NameDescription
NameFactory Name
DomainDomain Name

Options #

NameDescription
--forceForce create the Factory class

Listener #

Command for generate a Listener class to your project.

Command #

php artisan infrastructure:make:listener PostListener Post

Arguments #

NameDescription
NameListener name class
DomainDomain Name

Options #

Name `Description
--event=NameEventFor create Event class and use it into Listener class
--forceForce create the Listener class

Mail #

Command for generate a Mail class. This command will generate Mail class into Infrastructure side because this class purpose is store to external.

Command #

php artisan infrastructure:make:mail ApprovedUser User

Arguments #

NameDescription
NameMail name class
DomainDomain Name

Options #

NameDescription
--forceForce create the Mail class

Observer #

Command for generate an Observer class to your project.

Command #

php artisan infrastructure:make:observer UserObserver User

Arguments #

NameDescription
NameObserver name class
DomainDomain Name

Options #

NameDescription
--forceForce create the Observer class

Seeder #

Command for generate a Seeder class. This command will generate Seeder class into Infrastructure because this class purpose is to insert a test data into table.

Command #

php artisan infrastructure:make:seeder UserSeeder User

Arguments #

NameDescription
NameSeeder name class
DomainDomain Name

Options #

NameDescription
--forceForce create the Seeder class

Provider #

Command for generate a Service Provider class. This command will generate Service Provider class into Infrastructure to binds between Domain and Infrastructure.

Command #

php artisan infrastructure:make:provider FactoryServiceProvider User

Arguments #

NameDescription
NameService Provider name class
DomainDomain Name

Options #

NameDescription
--forceForce create the Service Provider class