Skip to content

Commit

Permalink
New commands roughed in.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspertey committed Apr 3, 2024
1 parent 13112ac commit bf0e570
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 15 deletions.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,28 @@ You can install the package via composer:
composer require lunarstorm/laravel-ddd
```

You may then initialize the package using the `ddd:install` artisan command. This command will publish the config file, register the domain path in your project's composer.json psr-4 autoload configuration on your behalf, and allow you to publish generator stubs for customization if needed.
You may initialize the package using the `ddd:install` artisan command. This will publish the config file, register the domain path in your project's composer.json psr-4 autoload configuration on your behalf, and allow you to publish generator stubs for customization if needed.
```bash
php artisan ddd:install
```

### Version Compatibility
Laravel | LaravelDDD
:---------------|:-----------
9.x - 10.24.x | 0.x
10.25.x | 1.x
11.x | 1.x
### Deployment
In production, run `ddd:cache` during the deployment process to optimize autoloading. See the [Autoloading in Production](#autoloading-in-production) section for more details.
```bash
php artisan ddd:cache
```

> For 0.x usage, please refer to the **[0.x README](https://github.com/lunarstorm/laravel-ddd/blob/v0.10.0/README.md)**.
>
### Version Compatibility
Laravel | LaravelDDD | Notes |
:---------------|:-----------|:-------------------------------------------------------------------------------------|
9.x - 10.24.x | 0.x | **[0.x README](https://github.com/lunarstorm/laravel-ddd/blob/v0.10.0/README.md)** |
10.25.x | 1.x |
11.x | 1.x |

### Upgrading from 0.x
Things to be aware of when upgrading from 0.x:
- If the config file was published, it should be removed, re-published, and re-configured according to the latest format. A helper command `ddd:upgrade` is available to assist with this.
- If stubs were published, they should also be re-published and inspected to ensure everything is up-to-date.
- Re-publish and update config. A helper command `ddd:upgrade` is available to assist with this.
- Remove and re-publish stubs if applicable.
- In production, `ddd:cache` should be run during the deployment process to optimize autoloading. See the [Autoloading in Production](#autoloading-in-production) section for more details.

## Usage
Expand Down Expand Up @@ -110,7 +113,7 @@ php artisan ddd:cache
php artisan ddd:clear
```

### Subdomains (nested domains)
## Subdomains (nested domains)
Subdomains can be specified with dot notation wherever a domain option is accepted.
```bash
# Domain/Reporting/Internal/ViewModels/MonthlyInvoicesReportViewModel
Expand All @@ -122,7 +125,7 @@ php artisan ddd:view-model Reporting.Customer:MonthlyInvoicesReportViewModel
# (supported by all commands where a domain option is accepted)
```

### Customization
## Customization
This package ships with opinionated (but sensible) configuration defaults. You may customize by publishing the config file and generator stubs as needed:

```bash
Expand Down
3 changes: 3 additions & 0 deletions config/ddd.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@
'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',
Expand All @@ -61,6 +63,7 @@
'resource' => 'Resources',
'rule' => 'Rules',
'scope' => 'Scopes',
'trait' => '',
],

/*
Expand Down
13 changes: 13 additions & 0 deletions src/Commands/DomainClassMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Lunarstorm\LaravelDDD\Commands;

use Illuminate\Foundation\Console\ClassMakeCommand;
use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;

class DomainClassMakeCommand extends ClassMakeCommand
{
use ResolvesDomainFromInput;

protected $name = 'ddd:class';
}
13 changes: 13 additions & 0 deletions src/Commands/DomainInterfaceMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Lunarstorm\LaravelDDD\Commands;

use Illuminate\Foundation\Console\InterfaceMakeCommand;
use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;

class DomainInterfaceMakeCommand extends InterfaceMakeCommand
{
use ResolvesDomainFromInput;

protected $name = 'ddd:interface';
}
13 changes: 13 additions & 0 deletions src/Commands/DomainTraitMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Lunarstorm\LaravelDDD\Commands;

use Illuminate\Foundation\Console\TraitMakeCommand;
use Lunarstorm\LaravelDDD\Commands\Concerns\ResolvesDomainFromInput;

class DomainTraitMakeCommand extends TraitMakeCommand
{
use ResolvesDomainFromInput;

protected $name = 'ddd:trait';
}
6 changes: 4 additions & 2 deletions src/LaravelDDDServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public function configurePackage(Package $package): void
Commands\DomainScopeMakeCommand::class,
]);

// Enum generator only in Laravel 11
if (app()->version() >= 11) {
$package->hasCommand(\Lunarstorm\LaravelDDD\Commands\DomainEnumMakeCommand::class);
$package->hasCommand(Commands\DomainClassMakeCommand::class);
$package->hasCommand(Commands\DomainEnumMakeCommand::class);
$package->hasCommand(Commands\DomainInterfaceMakeCommand::class);
$package->hasCommand(Commands\DomainTraitMakeCommand::class);
}
}

Expand Down

0 comments on commit bf0e570

Please sign in to comment.