1. Go to this page and download the library: Download lunarstorm/laravel-ddd library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return [
/*
|--------------------------------------------------------------------------
| Domain Path
|--------------------------------------------------------------------------
|
| The path to the domain folder relative to the application root.
|
*/
'domain_path' => 'src/Domain',
/*
|--------------------------------------------------------------------------
| Domain Namespace
|--------------------------------------------------------------------------
|
| The root domain namespace.
|
*/
'domain_namespace' => 'Domain',
/*
|--------------------------------------------------------------------------
| Domain Object Namespaces
|--------------------------------------------------------------------------
|
| This value contains the default namespaces of generated domain
| objects relative to the domain namespace of which the object
| belongs to.
|
| e.g., Domain\Invoicing\Models\*
| Domain\Invoicing\Data\*
| Domain\Invoicing\ViewModels\*
| Domain\Invoicing\ValueObjects\*
| Domain\Invoicing\Actions\*
|
*/
'namespaces' => [
'model' => 'Models',
'data_transfer_object' => 'Data',
'view_model' => 'ViewModels',
'value_object' => 'ValueObjects',
'action' => 'Actions',
'cast' => 'Casts',
'class' => '',
'channel' => 'Channels',
'command' => 'Commands',
'enum' => 'Enums',
'event' => 'Events',
'exception' => 'Exceptions',
'factory' => 'Database\Factories',
'interface' => '',
'job' => 'Jobs',
'listener' => 'Listeners',
'mail' => 'Mail',
'notification' => 'Notifications',
'observer' => 'Observers',
'policy' => 'Policies',
'provider' => 'Providers',
'resource' => 'Resources',
'rule' => 'Rules',
'scope' => 'Scopes',
'trait' => '',
],
/*
|--------------------------------------------------------------------------
| Base Model
|--------------------------------------------------------------------------
|
| The base class which generated domain models should extend. By default,
| generated domain models will extend `Domain\Shared\Models\BaseModel`,
| which will be created if it doesn't already exist.
|
*/
'base_model' => 'Domain\Shared\Models\BaseModel',
/*
|--------------------------------------------------------------------------
| Base DTO
|--------------------------------------------------------------------------
|
| The base class which generated data transfer objects should extend. By
| default, generated DTOs will extend `Spatie\LaravelData\Data` from
| Spatie's Laravel-data package, a highly recommended data object
| package to work with.
|
*/
'base_dto' => 'Spatie\LaravelData\Data',
/*
|--------------------------------------------------------------------------
| Base ViewModel
|--------------------------------------------------------------------------
|
| The base class which generated view models should extend. By default,
| generated domain models will extend `Domain\Shared\ViewModels\BaseViewModel`,
| which will be created if it doesn't already exist.
|
*/
'base_view_model' => 'Domain\Shared\ViewModels\ViewModel',
/*
|--------------------------------------------------------------------------
| Base Action
|--------------------------------------------------------------------------
|
| The base class which generated action objects should extend. By default,
| generated actions are based on the `lorisleiva/laravel-actions` package
| and do not extend anything.
|
*/
'base_action' => null,
/*
|--------------------------------------------------------------------------
| Autoloading
|--------------------------------------------------------------------------
|
| Configure whether domain providers, commands, policies, and factories
| should be auto-discovered and registered.
|
*/
'autoload' => [
/**
* When enabled, any class within the domain layer extending `Illuminate\Support\ServiceProvider`
* will be auto-registered as a service provider
*/
'providers' => true,
/**
* When enabled, any class within the domain layer extending `Illuminate\Console\Command`
* will be auto-registered as a command when running in console.
*/
'commands' => true,
/**
* When enabled, the package will register a custom policy discovery callback to resolve policy names
* for domain models, and fallback to Laravel's default for all other cases.
*/
'policies' => true,
/**
* When enabled, the package will register a custom factory discovery callback to resolve factory names
* for domain models, and fallback to Laravel's default for all other cases.
*/
'factories' => true,
],
/*
|--------------------------------------------------------------------------
| Autoload Ignore Folders
|--------------------------------------------------------------------------
|
| Folders that should be skipped during autoloading discovery,
| relative to the root of each domain.
|
| e.g., src/Domain/Invoicing/<folder-to-ignore>
|
| If more advanced filtering is needed, a callback can be registered
| using the `DDD::filterAutoloadPathsUsing(callback $filter)` in
| the AppServiceProvider's boot method.
|
*/
'autoload_ignore' => [
'Tests',
'Database/Migrations',
],
/*
|--------------------------------------------------------------------------
| Caching
|--------------------------------------------------------------------------
|
| The folder where the domain cache files will be stored. Used for domain
| autoloading.
|
*/
'cache_directory' => 'bootstrap/cache/ddd',
];