jobins/ddd-command

Domain Driven Architecture Generator cli for Laravel.

v2.0.0 2021-06-02 04:57 UTC

This package is auto-updated.

Last update: 2024-10-29 05:54:07 UTC


README

Introduction

In this architecture we will separate our application and domain layers. In default our application layer lies in 'App\Application' and domain in 'App\Domain' namespace; Further it can be configured from config file.

<?php

return [
    'application'     => 'App\Application',
    'domain'          => 'App\Domain',

    /**
     * |
     * | Base Controller Path
     * |
     */
    'controller_path' => 'App\Infrastructure\Controllers\Controller',
];

Installation

This tool is supposed to require only in the development phase. So you can install it as development dependencies.

composer require jobins/ddd-command --dev
Create a Controller
php artisan ddd:controller LoginController auth

Above Controller class can call from web.php as follows.

<?php

use App\Application\Auth\LoginController;

Route::get('login',[LoginController::class,'index']);
Route::post('login',[LoginController::class,'store']);
Create a FormRequest

Following command creates a Laravel's FomRequest Class in the application domain. i.e. in the app\Application\Auth\Requests\ directory. FormRequest is part of application layer rather than core business layer so it is supposed to be stored in the application directory.

php artisan ddd:request LoginRequest auth

Create a model

Below commands create a Transaction model into the Account domain. The Transaction models lies on app\Domain\Account\Models\Transaction.php file. Domain model is part of core buiness layer so it is supposed to be stored in the domain directory.

php artisan ddd:model Transaction Account

Domain Vs Application