### Run Installation Command Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Execute the installation command to publish configuration files and register necessary autoloading. ```bash php artisan ddd:install ``` -------------------------------- ### Install Laravel-DDD package Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Run these commands to install the package and initialize the DDD structure in a Laravel project. ```bash composer require tey/laravel-ddd php artisan ddd:install ``` -------------------------------- ### Artisan Command Examples Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Examples of using Artisan commands for generating objects and managing stubs. ```bash php artisan ddd:controller Invoicing:PaymentController --api # Controller [src/App/Api/Controllers/Invoicing/PaymentApiController.php] created successfully. ``` ```bash php artisan ddd:stub --list ``` ```bash php artisan ddd:stub ``` ```bash # Publish all stubs php artisan ddd:stub --all # Publish one or more stubs specified as arguments (see ddd:stub --list) php artisan ddd:stub model php artisan ddd:stub model dto action php artisan ddd:stub controller controller.plain controller.api # Options: # Publish and overwrite only the files that have already been published php artisan ddd:stub ... --existing # Overwrite any existing files php artisan ddd:stub ... --force ``` ```bash php artisan ddd:stub listener. ``` ```bash Publishing /stubs/ddd/listener.typed.queued.stub Publishing /stubs/ddd/listener.queued.stub Publishing /stubs/ddd/listener.typed.stub Publishing /stubs/ddd/listener.stub ``` -------------------------------- ### Complete ddd.php configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md A full example of the ddd.php configuration file structure. ```php 'src/Domain', 'domain_namespace' => 'Domain', 'application_path' => 'app/Modules', 'application_namespace' => 'App\\Modules', 'application_objects' => [ 'controller', 'request', 'middleware', ], 'layers' => [ 'Infrastructure' => 'src/Infrastructure', ], 'namespaces' => [ 'model' => 'Models', 'data_transfer_object' => 'Data', 'view_model' => 'ViewModels', 'value_object' => 'ValueObjects', 'action' => 'Actions', 'cast' => 'Casts', 'class' => '', 'channel' => 'Channels', 'command' => 'Commands', 'controller' => 'Controllers', 'enum' => 'Enums', 'event' => 'Events', 'exception' => 'Exceptions', 'factory' => 'Database\\Factories', 'interface' => '', 'job' => 'Jobs', 'listener' => 'Listeners', 'mail' => 'Mail', 'middleware' => 'Middleware', 'migration' => 'Database\\Migrations', 'notification' => 'Notifications', 'observer' => 'Observers', 'policy' => 'Policies', 'provider' => 'Providers', 'resource' => 'Resources', 'request' => 'Requests', 'rule' => 'Rules', 'scope' => 'Scopes', 'seeder' => 'Database\\Seeders', 'trait' => '', ], 'base_model' => null, 'base_dto' => 'Spatie\\LaravelData\\Data', 'base_view_model' => 'Domain\\Shared\\ViewModels\\ViewModel', 'base_action' => null, 'autoload' => [ 'providers' => true, 'commands' => true, 'policies' => true, 'factories' => true, 'migrations' => true, 'listeners' => false, ], 'autoload_ignore' => [ 'Tests', 'Database/Migrations', ], 'cache_directory' => 'bootstrap/cache/ddd', ]; ``` -------------------------------- ### Instantiate ObjectSchema Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Example of creating an ObjectSchema instance and accessing its properties. ```php use Tey\\\LaravelDDD\\\ValueObjects\\\ObjectSchema; $schema = new ObjectSchema( name: 'InvoiceController', namespace: 'App\\\Modules\\\Invoicing\\\Controllers', fullyQualifiedName: 'App\\\Modules\\\Invoicing\\\Controllers\\\InvoiceController', path: 'app/Modules/Invoicing/Controllers/InvoiceController.php', ); echo $schema->name; // 'InvoiceController' echo $schema->fullyQualifiedName; // 'App\\\Modules\\\Invoicing\\\Controllers\\\InvoiceController' ``` -------------------------------- ### Implement DomainFactory Definition Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Example implementation showing how to access the domain namespace within a factory definition. ```php class InvoiceFactory extends DomainFactory { protected function definition(): array { $domainNs = $this->domainNamespace(); // Output: 'Domain\' } } ``` -------------------------------- ### Execute complete domain setup commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Generate various domain components including models, actions, DTOs, controllers, and events using artisan commands. ```bash # Models php artisan ddd:model Invoicing:Invoice --all php artisan ddd:model Invoicing:LineItem -mf # Services/Actions php artisan ddd:action Invoicing:CreateInvoice php artisan ddd:action Invoicing:SendInvoice # Data objects php artisan ddd:dto Invoicing:CreateInvoicePayload php artisan ddd:value Shared:Money # API layer php artisan ddd:controller Invoicing:InvoiceController --resource --requests php artisan ddd:policy Invoicing:InvoicePolicy # Events php artisan ddd:event Invoicing:InvoiceCreated php artisan ddd:listener Invoicing:SendInvoiceEmail ``` -------------------------------- ### Install Laravel DDD Package Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Install the package via Composer to begin using DDD features in your Laravel project. ```bash composer require tey/laravel-ddd ``` -------------------------------- ### toArray() Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Gets the raw composer configuration as an array. ```APIDOC ## toArray() ### Description Get the raw composer configuration as an array. ### Returns - **array** - The composer configuration array. ``` -------------------------------- ### Custom Object Schema Resolver Example Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Demonstrates using CommandContext to conditionally return a custom ObjectSchema based on command options. ```php use Tey\\\LaravelDDD\\\ValueObjects\\\CommandContext; use Tey\\\LaravelDDD\\\Facades\\\DDD; use Tey\\\LaravelDDD\\\ValueObjects\\\ObjectSchema; DDD::resolveObjectSchemaUsing(function ( string $domainName, string $nameInput, string $type, CommandContext $context ): ?ObjectSchema { // Check if the --api flag was passed if ($context->command->option('api')) { // Return custom schema for API endpoints $name = str($nameInput)->replaceEnd('Controller', '')->finish('ApiController')->toString(); return new ObjectSchema( name: $name, namespace: "App\\Api\\Controllers\\{$domainName}", fullyQualifiedName: "App\\Api\\Controllers\\{$domainName}\\{$name}", path: "src/App/Api/Controllers/{$domainName}/{$name}.php", ); } return null; // Use default }); ``` -------------------------------- ### Custom Action Stub Implementation Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/stub-manager.md Example of a custom stub file using Laravel's {{ }} placeholder syntax for namespace and class name injection. ```php // Custom action stub with documentation model('Invoice'); $action = $domain->action('SendInvoice'); $dto = $domain->dto('InvoicePayload'); echo $invoice->fullyQualifiedName; // 'Domain\Invoicing\Models\Invoice' echo $action->fullyQualifiedName; // 'Domain\Invoicing\Actions\SendInvoice' ``` -------------------------------- ### boot(): self Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Boots the autoloader to discover and prepare domain components based on configuration. ```APIDOC ## boot() ### Description Boot the autoloader, discovering and preparing domain components based on configuration. ### Returns - **self** (AutoloadManager) - Returns the instance for method chaining. ``` -------------------------------- ### toJson() Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Gets the composer configuration as a formatted JSON string. ```APIDOC ## toJson() ### Description Get the composer configuration as a formatted JSON string. ### Returns - **string** - JSON-encoded composer configuration. ``` -------------------------------- ### Configuration Commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Commands for managing package configuration and initialization. ```bash php artisan ddd:config {action} ``` ```bash # Interactive menu php artisan ddd:config # Run wizard php artisan ddd:config wizard # Update configuration php artisan ddd:config update # Sync composer.json php artisan ddd:config composer ``` ```bash php artisan ddd:install ``` -------------------------------- ### Configure DDD via Wizard Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Launch the configuration wizard to interactively set up package preferences. ```bash php artisan ddd:config wizard ``` -------------------------------- ### DDD::getAutoloadFilter() Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-manager.md Get the registered autoload path filter callback, if any. ```APIDOC ## DDD::getAutoloadFilter() ### Description Get the registered autoload path filter callback, if any. ### Returns `?callable` — The registered filter callback, or `null` if not set. ``` -------------------------------- ### Boot and Run Autoloader Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Initialize the discovery process and register components with the Laravel application. These methods support method chaining. ```php $autoloader = DDD::autoloader(); $autoloader->boot()->run(); ``` -------------------------------- ### Edit Stub Command Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/stub-manager.md Example command to edit a published stub file. ```bash # Edit the action stub nano stubs/ddd/action.stub ``` -------------------------------- ### Get configuration values Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Access nested composer.json values using dot-notation. ```php $composer = DDD::composer(); $scripts = $composer->get('scripts', []); $require = $composer->get('require', []); ``` -------------------------------- ### Filter Framework Stubs Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/stub-manager.md Retrieves only the stubs that are currently available in the local Laravel installation. ```php $stubs = DDD::stubs()->frameworkStubs(); // Only includes stubs that actually exist in your Laravel installation ``` -------------------------------- ### Set Up Database for Domains Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Commands for creating and running migrations and seeders specifically scoped to domain modules. ```bash # Create migrations php artisan ddd:migration Invoicing:CreateInvoicesTable --create=invoices php artisan ddd:migration Invoicing:CreateLineItemsTable --create=line_items # Run migrations php artisan migrate # Create seeder php artisan ddd:seeder Invoicing:InvoiceSeeder # Run seeder php artisan db:seed --class=Domain\\Invoicing\\Database\\Seeders\\InvoiceSeeder ``` -------------------------------- ### Get specific autoload path Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Retrieve the path associated with a specific PSR-4 namespace. ```php $composer = DDD::composer(); $path = $composer->getAutoloadPath('Domain'); // Output: 'src/Domain' ``` -------------------------------- ### Get Registered Subscribers Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Retrieves an array of all registered event subscriber class names. ```php $subscribers = $autoloader->getRegisteredSubscribers(); // Output: ['Domain\Invoicing\Listeners\InvoicingSubscriber'] ``` -------------------------------- ### Get Registered Providers Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Retrieves an array of all registered service provider class names. ```php $providers = $autoloader->getRegisteredProviders(); ``` -------------------------------- ### Use Layer Class Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Demonstrates creating a layer from a namespace and resolving related namespaces. ```php use Tey\\\LaravelDDD\\\Support\\\Layer; $layer = Layer::fromNamespace('Domain\\\Invoicing'); echo $layer->namespace; // 'Domain\\\Invoicing' echo $layer->path; // 'src/Domain/Invoicing' $modelNs = $layer->namespaceFor('model'); // Output: 'Domain\\\Invoicing\\\Models' ``` -------------------------------- ### Get Registered Commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Retrieves an array of all registered console command class names. ```php $commands = $autoloader->getRegisteredCommands(); ``` -------------------------------- ### Working with Subdomains Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Shows how to define subdomains using dot notation or explicit arguments. ```php // Dot notation $domain = new Domain('Reporting.Internal'); // Or explicit $domain = new Domain('Reporting', 'Internal'); echo $domain->domain; // 'Reporting' echo $domain->subdomain; // 'Internal' echo $domain->domainWithSubdomain; // 'Reporting\Internal' ``` -------------------------------- ### Create a Complete Domain Module Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Workflow for scaffolding a full domain module including models, services, DTOs, events, controllers, and policies. ```bash # Create models with migrations and factories php artisan ddd:model Invoicing:Invoice --all php artisan ddd:model Invoicing:LineItem -mf php artisan ddd:model Invoicing:Payment -mf # Create services/actions php artisan ddd:action Invoicing:CreateInvoice php artisan ddd:action Invoicing:SendInvoice php artisan ddd:action Invoicing:MarkAsPaid # Create DTOs for API php artisan ddd:dto Invoicing:CreateInvoicePayload php artisan ddd:dto Invoicing:CreateLineItemPayload # Create events php artisan ddd:event Invoicing:InvoiceCreated php artisan ddd:event Invoicing:InvoiceSent php artisan ddd:event Invoicing:PaymentReceived # Create API controller and requests php artisan ddd:controller Invoicing:InvoiceController --resource --requests # Create policies php artisan ddd:policy Invoicing:InvoicePolicy ``` -------------------------------- ### Get Domain Namespace Signature Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Signature for the method used to retrieve the root domain namespace. ```php protected static function domainNamespace(): string ``` -------------------------------- ### Override Namespaces at Runtime Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Use an absolute path starting with / to override configured namespaces during generation. ```bash # The usual: generate a provider in the configured provider namespace php artisan ddd:provider Invoicing:InvoiceServiceProvider # -> Domain\Invoicing\Providers\InvoiceServiceProvider # Override the configured namespace at runtime php artisan ddd:provider Invoicing:/InvoiceServiceProvider # -> Domain\Invoicing\InvoiceServiceProvider # Generate an event inside the Models namespace (hypothetical) php artisan ddd:event Invoicing:/Models/EventDoesNotBelongHere # -> Domain\Invoicing\Models\EventDoesNotBelongHere # Deep nesting is supported php artisan ddd:exception Invoicing:/Models/Exceptions/InvoiceNotFoundException # -> Domain\Invoicing\Models\Exceptions\InvoiceNotFoundException ``` -------------------------------- ### Instantiate ConfigManager Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/config-manager.md Initialize the manager with either the default configuration path or a custom file path. ```php use Tey\LaravelDDD\ConfigManager; // Use the default config path $config = new ConfigManager(); // Use a custom config path $config = new ConfigManager('/path/to/custom-ddd.php'); ``` -------------------------------- ### boot(): self Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Manually triggers the autoloader boot process if not already booted. ```APIDOC ## boot() ### Description Initializes the autoloader discovery process. This is typically handled automatically but can be invoked manually. ### Signature `public function boot(): self` ### Example ```php $autoloader = DDD::autoloader(); if (!$autoloader->isBooted()) { $autoloader->boot()->run(); } ``` -------------------------------- ### get(string $path, mixed $default = null) Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Retrieves a value from the composer configuration using dot-notation. ```APIDOC ## get(string $path, mixed $default = null) ### Description Get a value from the composer configuration using dot-notation. ### Parameters - **path** (string) - Required - Dot-notation path (e.g., 'autoload.psr-4') - **default** (mixed) - Optional - Default value if not found ### Returns - **mixed** - The configuration value. ``` -------------------------------- ### Instantiate Domain objects Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Create new Domain instances using simple names or dot/slash-separated notation for subdomains. ```php use Tey\LaravelDDD\Support\Domain; // Simple domain $domain = new Domain('Invoicing'); // Subdomain notation (dot-separated) $domain = new Domain('Reporting.Internal'); // Subdomain notation (slash-separated) $domain = new Domain('Reporting', 'Internal'); ``` -------------------------------- ### Get Registered Listeners Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Retrieves an associative array mapping events to their registered listener class names. ```php $listeners = $autoloader->getRegisteredListeners(); // Output: [ // 'Invoicing.Paid' => ['Domain\Invoicing\Listeners\SendInvoiceEmail'], // ] ``` -------------------------------- ### Create an API resource descriptor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Initializes an API resource descriptor using the domain instance. ```php $domain = new Domain('Invoicing'); $resource = $domain->resource('InvoiceResource'); ``` -------------------------------- ### Configure base_view_model Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Sets the base class for generated View Models. This class is created automatically during installation if it does not exist. ```php 'base_view_model' => 'Domain\Shared\ViewModels\ViewModel', ``` -------------------------------- ### Get Resolved Factories Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Retrieves an associative array mapping model classes to their resolved factory class names. ```php $resolved = $autoloader->getResolvedFactories(); // Output: [ // 'Domain\Invoicing\Models\Invoice' => 'Domain\Invoicing\Database\Factories\InvoiceFactory', // ] ``` -------------------------------- ### Namespace Detection Walkthrough Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-object.md Illustrates the internal logic of the fromClass() method when parsing a class name against configured domain namespaces. ```php // Input class: 'Domain\Invoicing\Models\Invoice' // Configuration: config('ddd.namespaces.model') = 'Models' // Step 1: Is in domain namespace? ✓ // Step 2: Extract base name: 'Invoice' // Step 3: Scan config('ddd.namespaces'): // - Check for 'Models' pattern in full class // - Found: 'Domain\Invoicing\[Models]\Invoice' // Step 4: Extract domain from before the namespace: 'Invoicing' // Step 5: Build path: 'src/Domain/Invoicing/Models/Invoice.php' // Result: // DomainObject { // name: 'Invoice' // domain: 'Invoicing' // namespace: 'Models' // fullyQualifiedName: 'Domain\Invoicing\Models\Invoice' // path: 'src/Domain/Invoicing/Models/Invoice.php' // type: null // } ``` -------------------------------- ### Get Resolved Policies Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Retrieves an associative array mapping model classes to their resolved policy class names. ```php $resolved = $autoloader->getResolvedPolicies(); // Output: [ // 'Domain\Invoicing\Models\Invoice' => 'Domain\Invoicing\Policies\InvoicePolicy', // ] ``` -------------------------------- ### Generate basic model with migration and factory Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Use the artisan command to scaffold a domain model along with its associated database files. ```bash php artisan ddd:model Invoicing:Invoice --migration --factory ``` -------------------------------- ### Create an event descriptor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Initializes an event descriptor using the domain instance. ```php $domain = new Domain('Invoicing'); $event = $domain->event('PaymentWasReceived'); ``` -------------------------------- ### Create a notification descriptor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Initializes a notification descriptor using the domain instance. ```php $domain = new Domain('Invoicing'); $notif = $domain->notification('PaymentWasReceived'); ``` -------------------------------- ### Get domain object namespace Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-resolver.md Constructs the fully qualified namespace for a specific domain object, optionally including nested namespaces. ```php // Get model namespace $ns = DomainResolver::getDomainObjectNamespace('Invoicing', 'model'); // Output: 'Domain\Invoicing\Models' // Get action namespace with nesting $ns = DomainResolver::getDomainObjectNamespace('Invoicing', 'action', 'Payment/ProcessTransaction'); // Output: 'Domain\Invoicing\Actions\Payment\ProcessTransaction' ``` -------------------------------- ### Get relative object namespace Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-resolver.md Retrieves the configured namespace for a specific object type relative to its layer, based on the ddd.namespaces configuration. ```php $ns = DomainResolver::getRelativeObjectNamespace('model'); // Output: 'Models' $ns = DomainResolver::getRelativeObjectNamespace('action'); // Output: 'Actions' $ns = DomainResolver::getRelativeObjectNamespace('class'); // Output: '' (empty string for root-level) ``` -------------------------------- ### ConfigManager::__construct Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/config-manager.md Initializes a new instance of the ConfigManager, optionally specifying a custom path to the configuration file. ```APIDOC ## __construct(?string $configPath = null) ### Description Create a new ConfigManager instance. ### Parameters - **configPath** (string) - Optional - Path to the ddd.php config file. Defaults to config('app.config_path')/ddd.php. ``` -------------------------------- ### Generate a service provider Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates a service provider for the domain. ```bash php artisan ddd:provider Invoicing:InvoiceServiceProvider ``` -------------------------------- ### Manual boot in Service Provider Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Manually trigger the autoloader boot process within a service provider's boot method. ```php use Tey\LaravelDDD\Facades\DDD; public function boot() { // Discovery happens automatically, but you can manually trigger it $autoloader = DDD::autoloader(); if (!$autoloader->isBooted()) { $autoloader->boot()->run(); } } ``` -------------------------------- ### Specify Domains in Artisan Commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Demonstrates various ways to specify domains when running artisan commands, including option flags, shorthand notation, and interactive prompts. ```bash # Option format php artisan ddd:model Invoice --domain=Invoicing # Short-hand format (preferred) php artisan ddd:model Invoicing:Invoice # Prompted (no domain specified) php artisan ddd:model Invoice # → What domain should this belong to? [Invoicing] ``` -------------------------------- ### Deployment Optimization Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Commands to optimize the application and domain structure for production environments. ```bash # Optimize autoloading php artisan ddd:optimize # Standard Laravel optimization php artisan optimize ``` -------------------------------- ### Sync Composer Configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Use the helper command to sync composer.json namespaces with ddd.php configuration. ```bash # Sync composer.json with ddd.php php artisan ddd:config composer ``` -------------------------------- ### Check Boot Status Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Verify if the autoloader has been initialized before performing operations. ```php if (!$autoloader->isBooted()) { $autoloader->boot(); } ``` -------------------------------- ### Generate a view model Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates a view model for the specified domain. ```bash php artisan ddd:view-model Invoicing:ShowInvoiceViewModel ``` -------------------------------- ### Sync Configuration with Latest Schema Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/config-manager.md Merge current user settings with the latest package configuration to incorporate new keys. ```php $config = DDD::config(); // Update to the latest configuration schema $config->syncWithLatest()->save(); ``` -------------------------------- ### Manage Configuration Caching Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Use these commands to cache or clear configuration settings for production and development environments. ```bash # Production php artisan config:cache # Development php artisan config:clear ``` -------------------------------- ### Building Object Paths Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Shows how to resolve fully qualified names for models using domain paths. ```php $domain = new Domain('Invoicing'); $invoice = $domain->model('Invoice'); $lineItem = $domain->model('LineItem'); $payment = $domain->model('Payment/Transaction'); echo $invoice->fullyQualifiedName; // 'Domain\Invoicing\Models\Invoice' echo $payment->fullyQualifiedName; // 'Domain\Invoicing\Models\Payment\Transaction' ``` -------------------------------- ### List domain summaries with ddd:list Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Displays a summary of all domains, including their paths and component counts. ```bash php artisan ddd:list ``` ```text Domain Summary ============== Domain: Invoicing ├─ Path: src/Domain/Invoicing ├─ Models: 3 ├─ Actions: 5 └─ Migrations: 2 Domain: Reporting ├─ Path: src/Domain/Reporting ├─ Models: 2 ├─ ViewModels: 3 └─ Migrations: 1 ``` -------------------------------- ### DDD Utility Commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Summary of utility commands for managing domain summaries, configuration, and caching. ```bash ddd:list # Domain summary ddd:config # Configuration management ddd:install # Initial setup ddd:stub # Stub customization ddd:optimize # Cache auto-discovered components ddd:clear # Clear caches ``` -------------------------------- ### Configure Laravel-DDD Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Commands for managing the package configuration file. ```bash php artisan ddd:config wizard ``` ```bash php artisan ddd:config update ``` -------------------------------- ### run(): self Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/autoload-manager.md Registers all discovered components with the Laravel application. ```APIDOC ## run() ### Description Register all discovered components with the Laravel application. ### Returns - **self** (AutoloadManager) - Returns the instance for method chaining. ``` -------------------------------- ### Creating DomainObject from Class Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-object.md Shows how to inspect a domain class to create a DomainObject instance, returning null for non-domain classes. ```php use Tey\LaravelDDD\ValueObjects\DomainObject; // Inspect an existing domain model $obj = DomainObject::fromClass('Domain\Invoicing\Models\Invoice', 'model'); if ($obj) { echo $obj->name; // 'Invoice' echo $obj->domain; // 'Invoicing' echo $obj->type; // 'model' } // Non-domain class returns null $obj = DomainObject::fromClass('App\Models\User'); // Output: null ``` -------------------------------- ### Generate components for subdomains Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Use dot notation to organize components within specific subdomains. ```bash php artisan ddd:model Reporting.Internal:MonthlyReport php artisan ddd:view-model Reporting.Customer:CustomerMetricsViewModel ``` -------------------------------- ### Generate Interface Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Creates a new interface within the specified domain. ```bash php artisan ddd:interface Customer:Contracts/Invoiceable ``` -------------------------------- ### Configure Domain Autoloading Options Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Define which components are automatically discovered and registered by the package. ```php 'autoload' => [ 'providers' => true, 'commands' => true, 'policies' => true, 'factories' => true, 'migrations' => true, 'listeners' => false, ], ``` -------------------------------- ### Generate an action class Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates an action class for handling domain logic. ```bash php artisan ddd:action Invoicing:SendInvoiceToCustomer ``` -------------------------------- ### Run project tests Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Executes the test suite for the project using Composer. ```bash composer test ``` -------------------------------- ### Access DDD configuration and domain utilities Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Use the DDD facade to retrieve configuration settings and instantiate domain objects for specific modules. ```php use Tey\WLaravelDDD\WFacades\WDDD; // Access configuration $config = DDD::config()->get('domain_path'); // Access domain utilities $domain = new \WTey\WLaravelDDD\WSupport\WDomain('Invoicing'); $model = $domain->model('Invoice'); echo $model->fullyQualifiedName; // 'Domain\WInvoicing\WModels\WInvoice' ``` -------------------------------- ### Create a validation rule descriptor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Initializes a validation rule descriptor using the domain instance. ```php $domain = new Domain('Invoicing'); $rule = $domain->rule('ValidPaymentMethod'); ``` -------------------------------- ### Configure Autoload Migrations Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Enable auto-discovery for database migrations. ```php 'autoload' => [ 'migrations' => true, // Enable auto-discovery ], ``` -------------------------------- ### Automated Upgrade to v3.0.0 Source: https://github.com/jaspertey/laravel-ddd/blob/main/UPGRADING.md Use the built-in upgrade command to handle namespace migrations and package replacement automatically. ```bash composer require lunarstorm/laravel-ddd:"^2.1.2" php artisan ddd:upgrade ``` -------------------------------- ### Display project file structure Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/MANIFEST.md Visual representation of the documentation directory layout for the Laravel-DDD package. ```text /workspace/home/output/ ├── INDEX.md # Master index and navigation ├── README.md # Quick start and concepts ├── package-info.md # Package overview ├── types.md # Type definitions ├── configuration.md # Configuration reference ├── artisan-commands.md # Command reference ├── api-reference/ │ ├── domain-manager.md # Central manager API │ ├── config-manager.md # Config file management │ ├── composer-manager.md # Composer integration │ ├── autoload-manager.md # Discovery system │ ├── domain-resolver.md # Static utilities │ ├── domain.md # Domain instance API │ ├── domain-object.md # Class metadata API │ ├── stub-manager.md # Template management │ └── factory-support.md # Factory integration └── MANIFEST.md # This file ``` -------------------------------- ### View Documentation Map Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md A structural overview of the available documentation files within the package. ```text README.md (this file) ├── api-reference/ │ ├── domain-manager.md │ ├── config-manager.md │ ├── composer-manager.md │ ├── autoload-manager.md │ ├── domain-resolver.md │ ├── domain.md │ ├── domain-object.md │ ├── stub-manager.md │ └── factory-support.md ├── types.md ├── configuration.md └── artisan-commands.md ``` -------------------------------- ### Configure Autoload Commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Enable auto-discovery for console commands. ```php 'autoload' => [ 'commands' => true, // Enable auto-discovery ], ``` -------------------------------- ### Create Single Model Instance Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Demonstrates using a factory to create a single model instance with specific attributes in a test. ```php use Domain\Invoicing\Models\Invoice; use Tests\TestCase; class InvoiceTest extends TestCase { public function test_invoice_creation() { $invoice = Invoice::factory()->create([ 'status' => 'sent', ]); $this->assertDatabaseHas('invoices', [ 'id' => $invoice->id, 'status' => 'sent', ]); } } ``` -------------------------------- ### Generate Model and Factory Together Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Use the --factory flag to generate both the model and its corresponding factory simultaneously. ```bash php artisan ddd:model Invoicing:Invoice --factory ``` -------------------------------- ### Configure Autoload Factories Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Enable auto-discovery for model factories. ```php 'autoload' => [ 'factories' => true, // Enable auto-discovery // Automatically resolves Domain\X\Models\Y to Domain\X\Database\Factories\YFactory ], ``` -------------------------------- ### List Available DDD Generators Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md View the list of available artisan commands for generating domain-driven components. ```bash ddd:model, ddd:factory, ddd:dto, ddd:value, ddd:view-model, ddd:action, ddd:cast, ddd:channel, ddd:command, ddd:controller, ddd:event, ddd:exception, ddd:job, ddd:listener, ddd:mail, ddd:middleware, ddd:migration, ddd:notification, ddd:observer, ddd:policy, ddd:provider, ddd:resource, ddd:rule, ddd:request, ddd:scope, ddd:seeder, ddd:class, ddd:enum, ddd:interface, ddd:trait ``` -------------------------------- ### Manual Package Migration Source: https://github.com/jaspertey/laravel-ddd/blob/main/UPGRADING.md Manually replace the old package with the new package namespace. ```bash composer remove lunarstorm/laravel-ddd composer require tey/laravel-ddd:^3.0 ``` -------------------------------- ### Generate Class Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Creates a generic class within the specified domain. ```bash php artisan ddd:class Invoicing:Support/InvoiceBuilder ``` -------------------------------- ### Instantiate ComposerManager via Constructor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Create a new instance using the constructor, optionally specifying a custom path to the composer.json file. ```php use Tey\LaravelDDD\ComposerManager; $composer = new ComposerManager(); // or with custom path: $composer = new ComposerManager('/path/to/composer.json'); ``` -------------------------------- ### Management Commands Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Commands for listing domains and managing the domain cache. ```bash # Show a summary of current domains in the domain folder php artisan ddd:list # Cache domain manifests (used for autoloading) php artisan ddd:optimize # Clear the domain cache php artisan ddd:clear ``` -------------------------------- ### Instantiate a DomainObject Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-object.md Create a new instance of DomainObject using named arguments for clarity. ```php use Tey\\\LaravelDDD\\ValueObjects\\DomainObject; $obj = new DomainObject( name: 'Invoice', domain: 'Invoicing', namespace: 'Domain\\Invoicing\\Models', fullyQualifiedName: 'Domain\\Invoicing\\Models\\Invoice', path: 'src/Domain/Invoicing/Models/Invoice.php', type: 'model' ); ``` -------------------------------- ### Re-publish Configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/UPGRADING.md Force update the package configuration file. ```bash php artisan vendor:publish --tag=ddd-config --force ``` -------------------------------- ### Configure Autoload Policies Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Enable auto-discovery for model policies. ```php 'autoload' => [ 'policies' => true, // Enable auto-discovery // Automatically resolves Domain\X\Models\Y to Domain\X\Policies\YPolicy ], ``` -------------------------------- ### Autoloading Configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Specifies which components should be automatically registered by the package. ```php 'autoload' => [ 'providers' => true, // Service providers 'commands' => true, // Console commands 'policies' => true, // Authorization policies 'factories' => true, // Model factories 'migrations' => true, // Database migrations 'listeners' => false, // Event listeners (opt-in) ], ``` -------------------------------- ### Essential Configuration Settings Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Defines the directory structure and namespace conventions for domains and application modules. ```php 'domain_path' => 'src/Domain', 'domain_namespace' => 'Domain', 'application_path' => 'app/Modules', 'application_namespace' => 'App\Modules', ``` -------------------------------- ### Create a custom exception descriptor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain.md Initializes a custom exception descriptor using the domain instance. ```php $domain = new Domain('Invoicing'); $exc = $domain->exception('InvoiceNotFoundException'); ``` -------------------------------- ### Creating Objects from Domain Class Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-object.md Recommended pattern for creating a DomainObject with an explicit type hint to ensure accuracy. ```php use Tey\LaravelDDD\ValueObjects\DomainObject; $class = 'Domain\Invoicing\Models\Invoice'; // With type hint (recommended for accuracy) $obj = DomainObject::fromClass($class, 'model'); if ($obj && $obj->domain === 'Invoicing') { echo "Found Invoice model in Invoicing domain"; echo "Class: " . $obj->fullyQualifiedName; } ``` -------------------------------- ### Retrieve Application Layer Configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/config-manager.md Access path, namespace, and object definitions for the application layer. ```php $config->get('application_path') // string: 'app/Modules' $config->get('application_namespace') // string: 'App\Modules' $config->get('application_objects') // array: ['controller', 'request', 'middleware'] ``` -------------------------------- ### Instantiate ComposerManager via Factory Method Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Create a new instance using the static make factory method. ```php use Tey\LaravelDDD\ComposerManager; $composer = ComposerManager::make(); ``` -------------------------------- ### Generate Domain Model Source: https://github.com/jaspertey/laravel-ddd/blob/main/README.md Creates a new domain model with optional migration, factory, seeder, controller, and policy files. ```bash php artisan ddd:model Invoicing:Invoice ``` -------------------------------- ### Programmatic Configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Updates and saves configuration settings at runtime. ```php use Tey\LaravelDDD\Facades\DDD; DDD::config() ->syncWithLatest() ->set('domain_path', 'src/Domain') ->set('domain_namespace', 'Domain') ->fill([ 'application_path' => 'app/Modules', 'application_namespace' => 'App\Modules', ]) ->save(); ``` -------------------------------- ### Instantiate DomainNamespaces Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Create a new DomainNamespaces instance by defining the relative namespaces for various domain object types. ```php $namespaces = new DomainNamespaces( model: 'Models', action: 'Actions', controller: 'Controllers', // ... other namespaces ); ``` -------------------------------- ### Resolve Factory for Domain Model Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-object.md Demonstrates constructing a factory class name using metadata extracted from a DomainObject instance. ```php use Tey\LaravelDDD\ValueObjects\DomainObject; $model = DomainObject::fromClass('Domain\Invoicing\Models\Invoice', 'model'); if ($model) { $factoryClass = sprintf( '%s\%s\%sFactory', 'Domain', $model->domain, $model->name ); } ``` -------------------------------- ### Optimize Factory Discovery Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Caches factory discovery for improved performance in production environments. ```bash php artisan ddd:optimize ``` -------------------------------- ### Configure Laravel DDD essential options Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Define paths, namespaces, and auto-discovery settings for domain and application layers in the configuration file. ```php // Domain layer 'domain_path' => 'src/Domain', 'domain_namespace' => 'Domain', // Application layer 'application_path' => 'app/Modules', 'application_namespace' => 'App\Modules', // Custom layers 'layers' => [ 'Infrastructure' => 'src/Infrastructure', ], // Auto-discovery 'autoload' => [ 'providers' => true, 'commands' => true, 'policies' => true, 'factories' => true, 'migrations' => true, 'listeners' => false, ], ``` -------------------------------- ### Generate an event class Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates an event class for the domain. ```bash php artisan ddd:event Invoicing:PaymentWasReceived ``` -------------------------------- ### Instantiate StubManager Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/stub-manager.md Create a new instance of the StubManager directly or via the DDD facade. ```php use Tey\LaravelDDD\StubManager; $stubs = new StubManager(); // or via DDD facade: $stubs = DDD::stubs(); ``` -------------------------------- ### Update Configuration File Source: https://github.com/jaspertey/laravel-ddd/blob/main/UPGRADING.md Rebuild the published configuration to include new layer support. ```bash php artisan ddd:config update ``` -------------------------------- ### Generate a database migration Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates a database migration for the domain, supporting table creation or modification. ```bash php artisan ddd:migration Invoicing:CreateInvoicesTable ``` -------------------------------- ### Project Directory Structure Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/package-info.md Overview of the source code organization for the package. ```text src/ ├── Commands/ # 36+ generator/utility commands ├── Support/ # Core utilities (AutoloadManager, Domain, etc.) ├── ValueObjects/ # Immutable data objects ├── Enums/ # LayerType enum ├── Factories/ # Factory support (DomainFactory, HasDomainFactory) ├── Events/ # Package events ├── Listeners/ # Event listeners ├── Facades/ # DDD facade ├── Models/ # Package models (if any) ├── ConfigManager.php # Configuration management ├── ComposerManager.php # Composer integration ├── DomainManager.php # Central registry ├── StubManager.php # Stub management └── LaravelDDDServiceProvider.php ``` -------------------------------- ### Namespace Replacement Source: https://github.com/jaspertey/laravel-ddd/blob/main/UPGRADING.md Update application code to reflect the new package namespace. ```text Lunarstorm\LaravelDDD → Tey\LaravelDDD ``` -------------------------------- ### Generate Domain Factory via Artisan Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Use the artisan command to scaffold a new factory for a specific domain model. ```bash php artisan ddd:factory Invoicing:InvoiceFactory ``` -------------------------------- ### Resolve Factory Name Usage Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/factory-support.md Demonstrates resolving factory classes for domain models versus standard models. ```php use Tey\LaravelDDD\Factories\DomainFactory; // Resolve factory for a domain model $factoryClass = DomainFactory::resolveFactoryName('Domain\Invoicing\Models\Invoice'); // Output: 'Domain\Invoicing\Database\Factories\InvoiceFactory' // or 'Database\Factories\Invoicing\InvoiceFactory' // Non-domain model returns null $factoryClass = DomainFactory::resolveFactoryName('App\Models\User'); // Output: null ``` -------------------------------- ### Resolve file paths with DomainResolver::guessPathFromClass Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-resolver.md Determine the absolute file system path for a given domain class. ```php public static function guessPathFromClass(string $class): ?string ``` ```php $path = DomainResolver::guessPathFromClass('Domain\Invoicing\Models\Invoice'); // Output: '/app/src/Domain/Invoicing/Models/Invoice.php' ``` -------------------------------- ### Development Cleanup Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Commands to clear caches and refresh configuration files during development. ```bash # Clear cache php artisan ddd:clear # Composer autoloader changes php artisan ddd:config composer ``` -------------------------------- ### Publish Stubs Source: https://github.com/jaspertey/laravel-ddd/blob/main/UPGRADING.md Use the new command to publish stubs for customization. ```bash php artisan ddd:stub ``` -------------------------------- ### DDD::composer() Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Initializes the composer manager to configure PSR-4 autoloading settings. ```APIDOC ## DDD::composer() ### Description Initializes the composer manager instance to define PSR-4 autoloading rules for the project. ### Methods - **registerPsr4Autoload(string $namespace, string $path = null)**: Registers a PSR-4 namespace mapping. If the path is omitted, it defaults to the namespace name. - **saveAndReload()**: Persists the configuration changes to the composer file and triggers a reload. ``` -------------------------------- ### Generate a model observer Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates a model observer for the domain. ```bash php artisan ddd:observer Invoicing:InvoiceObserver ``` -------------------------------- ### __construct(?string $composerFile = null) Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/composer-manager.md Creates a new instance of the ComposerManager, optionally specifying a custom path to the composer.json file. ```APIDOC ## __construct(?string $composerFile = null) ### Description Initializes a new ComposerManager instance. If no path is provided, it defaults to the application's base composer.json file. ### Parameters - **composerFile** (string) - Optional - Path to the composer.json file. Defaults to {basePath}/composer.json. ### Example ```php use Tey\LaravelDDD\ComposerManager; $composer = new ComposerManager(); $composer = new ComposerManager('/path/to/composer.json'); ``` ``` -------------------------------- ### Configure Autoload Listeners Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Enable auto-discovery for event listeners. ```php 'autoload' => [ 'listeners' => false, // Disabled by default (opt-in) // When enabled, discovers: // - Methods with #[ListensTo] attribute // - Listeners with $listen property // - Subscribers with subscribe() method ], ``` -------------------------------- ### Listing Available Stubs Programmatically Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/stub-manager.md Retrieve and iterate through available DDD and framework stubs using the DDD facade. ```php use Tey\LaravelDDD\Facades\DDD; $stubs = DDD::stubs(); echo "=== DDD Stubs ===\n"; foreach ($stubs->dddStubs() as $path => $name) { echo "- $name\n"; } echo "\n=== Framework Stubs ===\n"; foreach ($stubs->frameworkStubs() as $path => $name) { echo "- $name\n"; } echo "\nTotal: " . count($stubs->allStubs()) . " stubs"; ``` -------------------------------- ### Define Layer Constructor Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Initializes a new Layer instance with a namespace, optional path, and layer type. ```php public function __construct( string $namespace, ?string $path = null, public ?LayerType $type = null, ) ``` -------------------------------- ### Fill Multiple Configuration Values Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/config-manager.md Update multiple configuration settings simultaneously by passing an associative array. ```php $config = DDD::config(); $config->fill([ 'domain_path' => 'src/Domain', 'domain_namespace' => 'Domain', 'application_path' => 'app/Modules', ]); ``` -------------------------------- ### Generate a mailable class Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/artisan-commands.md Creates a mailable class for the domain. ```bash php artisan ddd:mail Invoicing:OverduePaymentReminderEmail ``` -------------------------------- ### Manage DDD Configuration Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/README.md Commands to interact with the DDD configuration wizard, updates, detection, and composer settings. ```bash php artisan ddd:config wizard php artisan ddd:config update php artisan ddd:config detect php artisan ddd:config composer ``` -------------------------------- ### Define Layer Methods Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Static and instance methods for resolving namespaces and paths within a layer. ```php public static function fromNamespace(string $namespace): self public function path(?string $path = null): string public function namespaceFor(string $type, ?string $name = null): string public function guessNamespaceFromName(string $name): string ``` -------------------------------- ### Instantiate DomainObjectNamespace Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/types.md Create a new DomainObjectNamespace instance to map a specific object type to its relative namespace. ```php $ns = new DomainObjectNamespace( type: 'model', namespace: 'Models', ); ``` -------------------------------- ### Using DomainObject as an array key Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/api-reference/domain-object.md Demonstrates how to use the fullyQualifiedName property of a DomainObject as a key in an associative array. ```php $objects = []; $invoice = $domain->model('Invoice'); $payment = $domain->model('Payment'); $objects[$invoice->fullyQualifiedName] = $invoice; $objects[$payment->fullyQualifiedName] = $payment; ``` -------------------------------- ### Define Environment Variables Source: https://github.com/jaspertey/laravel-ddd/blob/main/_autodocs/configuration.md Set these variables in your .env file to override default DDD configuration paths and directories. ```text DDD_DOMAIN_PATH=src/Domain DDD_DOMAIN_NAMESPACE=Domain DDD_CACHE_DIRECTORY=storage/framework/cache/ddd ```