Development › Modules

Modules

Every business capability lives in app/Modules/{Name}.

#Creating a module

php artisan make:module Orders

This scaffolds:

app/Modules/Orders/
├── Domain/{Entities,ValueObjects,Events,Exceptions,Contracts}/
├── Application/{Actions,Commands,Queries,DTOs,Services}/
├── Infrastructure/{Persistence,Repositories,Services,Consumers,Providers}/
└── Presentation/{Controllers,Requests,Resources,Routes}/

It also creates:

Register the provider in bootstrap/providers.php:

use App\Modules\Orders\Infrastructure\Providers\OrdersServiceProvider;

return [
    App\Providers\AppServiceProvider::class,
    OrdersServiceProvider::class,
];

#Generating module artifacts

php artisan make:action CreateOrder --module=Orders
php artisan make:dto CreateOrderData --module=Orders
php artisan make:domain-event OrderCreated --module=Orders
php artisan make:consumer OrderCreatedConsumer --module=Orders
POST /api/v1/orders
  → CreateOrderRequest (validation)
  → CreateOrderData (DTO)
  → CreateOrder Action
  → OrderRepository (contract)
  → Infrastructure repository
  → OrderCreated domain event
  → EventBus (local +/or Kafka)

#Module communication

Allowed

Not allowed

#Isolation checklist

  1. Domain has no Laravel facades
  2. Controllers only call Actions
  3. Repository interfaces live in Domain; implementations in Infrastructure
  4. Provider binds contracts and loads routes
  5. Routes stay inside the module (not in routes/api.php)

#Modules shipped in this starter

ModulePurpose
AuthAuthentication boundaries (Sanctum)
UsersUser identity / profile shell
NotificationsOutbound notification capability (LogNotifier)

Add your domain modules with php artisan make:module {Name}. See architecture.md and development.md.

Edit this page on GitHub