Skip to content

Commit

Permalink
[1.2] Official Release (#77)
Browse files Browse the repository at this point in the history
* [1.2] ddd:model options, migrations, application layer (#69)
* [1.2] Refactoring stubs (#71)
* [1.2] Custom Layers (#76)
  • Loading branch information
jaspertey authored Nov 23, 2024
1 parent f834953 commit 08a6ebb
Show file tree
Hide file tree
Showing 151 changed files with 6,479 additions and 1,209 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
run: composer show -D

- name: Execute tests
run: vendor/bin/pest
run: vendor/bin/pest --ci
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,59 @@

All notable changes to `laravel-ddd` will be documented in this file.

## [Unreleased]
### Breaking
- Stubs are now published to `base_path('stubs/ddd')` instead of `resource_path('stubs/ddd')`. In other words, they are now co-located alongside the framework's published stubs, within a ddd subfolder.
- Published stubs now use `.stub` extension instead of `.php.stub` (following Laravel's convention).
- If you are using published stubs from pre 1.2, you will need to refactor your stubs accordingly.

### Added
- Support for the Application Layer, to generate domain-specific objects that don't belong directly in the domain layer:
```php
// In config/ddd.php
'application_path' => 'app/Modules',
'application_namespace' => 'App\Modules',
'application_objects' => [
'controller',
'request',
'middleware',
],
```
- Support for Custom Layers, additional top-level namespaces of your choosing, such as `Infrastructure`, `Integrations`, etc.:
```php
// In config/ddd.php
'layers' => [
'Infrastructure' => 'src/Infrastructure',
],
```
- Added config utility command `ddd:config` to help manage the package's configuration over time.
- Added stub utility command `ddd:stub` to publish one or more stubs selectively.
- Added `ddd:controller` to generate domain-specific controllers.
- Added `ddd:request` to generate domain-spefic requests.
- Added `ddd:middleware` to generate domain-specific middleware.
- Added `ddd:migration` to generate domain migrations.
- Added `ddd:seeder` to generate domain seeders.
- Added `ddd:stub` to manage stubs.
- Migration folders across domains will be registered and scanned when running `php artisan migrate`, in addition to the standard application `database/migrations` path.
- Ability to customize generator object naming conventions with your own logic using `DDD::resolveObjectSchemaUsing()`.

### Changed
- `ddd:model` now extends Laravel's native `make:model` and inherits all standard options:
- `--migration|-m`
- `--factory|-f`
- `--seed|-s`
- `--controller --resource --requests|-crR`
- `--policy`
- `-mfsc`
- `--all|-a`
- `--pivot|-p`
- `ddd:cache` is now `ddd:optimize` (`ddd:cache` is still available as an alias).
- Since Laravel 11.27.1, the framework's `optimize` and `optimize:clear` commands will automatically invoke `ddd:optimize` (`ddd:cache`) and `ddd:clear` respectively.

### Deprecated
- Domain base models are no longer required by default, and `config('ddd.base_model')` is now `null` by default.
- Stubs are no longer published via `php artisan vendor:publish --tag="ddd-stubs"`. Instead, use `php artisan ddd:stub` to manage them.

## [1.1.3] - 2024-11-05
### Chore
- Allow `laravel/prompts` dependency to use latest version when possible.
Expand Down
393 changes: 285 additions & 108 deletions README.md

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Upgrading

## From 0.x to 1.x

## From 1.1.x to 1.2.x
### Breaking
- Stubs are now published to `base_path('stubs/ddd')` instead of `resource_path('stubs/ddd')`. In other words, they are now co-located alongside the framework's published stubs, within a ddd subfolder.
- Published stubs now use `.stub` extension instead of `.php.stub` (following Laravel's convention).
- If you are using published stubs from pre 1.2, you will need to refactor your stubs accordingly.

### Update Config
- Support for Application Layer and Custom Layers was added, introducing changes to the config file.
- Run `php artisan ddd:config update` to rebuild your application's published `ddd.php` config to align with the package's latest copy.
- The update utility will attempt to respect your existing customizations, but you should still review and verify manually.

### Publishing Stubs
- Old way (removed): `php artisan vendor:publish --tag="ddd-stubs"`
- New way: `php artisan ddd:stub` (see [Customizing Stubs](README.md#customizing-stubs) in README for more details).

## From 0.x to 1.x
- Minimum required Laravel version is 10.25.
- The ddd generator [command syntax](README.md#usage) in 1.x. Generator commands no longer receive a domain argument. For example, instead of `ddd:action Invoicing CreateInvoice`, one of the following would be used:
- Using the --domain option: ddd:action CreateInvoice --domain=Invoicing (this takes precedence).
Expand Down
21 changes: 15 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@
"require": {
"php": "^8.1|^8.2|^8.3",
"illuminate/contracts": "^10.25|^11.0",
"laravel/prompts": "^0.1.16|^0.3.1",
"laravel/pint": "^1.18",
"laravel/prompts": "^0.1.16|^0.2|^0.3.1",
"lorisleiva/lody": "^0.5.0",
"spatie/laravel-package-tools": "^1.13.0"
"spatie/laravel-package-tools": "^1.13.0",
"symfony/var-exporter": "^6|^7.1"
},
"require-dev": {
"larastan/larastan": "^2.0.1",
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.0|^8.1",
"orchestra/testbench": "^8|^9.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0"
"phpstan/phpstan-phpunit": "^1.0",
"spatie/laravel-data": "^4.11.1"
},
"suggest": {
"spatie/laravel-data": "Recommended for Data Transfer Objects.",
"lorisleiva/laravel-actions": "Recommended for Actions."
},
"autoload": {
"psr-4": {
Expand All @@ -47,14 +53,17 @@
"App\\": "vendor/orchestra/testbench-core/laravel/app",
"Database\\Factories\\": "vendor/orchestra/testbench-core/laravel/database/factories",
"Database\\Seeders\\": "vendor/orchestra/testbench-core/laravel/database/seeders",
"Domain\\": "vendor/orchestra/testbench-core/laravel/src/Domain"
"Domain\\": "vendor/orchestra/testbench-core/laravel/src/Domain",
"Application\\": "vendor/orchestra/testbench-core/laravel/src/Application",
"Infrastructure\\": "vendor/orchestra/testbench-core/laravel/src/Infrastructure"
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"analyse": "vendor/bin/phpstan analyse",
"test": "@composer dump-autoload && vendor/bin/pest",
"test-coverage": "@composer dump-autoload && vendor/bin/pest --coverage",
"purge-skeleton": "vendor/bin/testbench package:purge-skeleton",
"format": "vendor/bin/pint",
"lint": "vendor/bin/pint"
},
Expand All @@ -71,7 +80,7 @@
"Lunarstorm\\LaravelDDD\\LaravelDDDServiceProvider"
],
"aliases": {
"LaravelDDD": "Lunarstorm\\LaravelDDD\\Facades\\LaravelDDD"
"DDD": "Lunarstorm\\LaravelDDD\\Facades\\DDD"
}
}
},
Expand Down
82 changes: 43 additions & 39 deletions config/ddd.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,56 @@

/*
|--------------------------------------------------------------------------
| Domain Path
| Domain Layer
|--------------------------------------------------------------------------
|
| The path to the domain folder relative to the application root.
| The path and namespace of the domain layer.
|
*/
'domain_path' => 'src/Domain',
'domain_namespace' => 'Domain',

/*
|--------------------------------------------------------------------------
| Domain Namespace
| Application Layer
|--------------------------------------------------------------------------
|
| The root domain namespace.
| The path and namespace of the application layer, and the objects
| that should be recognized as part of the application layer.
|
*/
'domain_namespace' => 'Domain',
'application_path' => 'app/Modules',
'application_namespace' => 'App\Modules',
'application_objects' => [
'controller',
'request',
'middleware',
],

/*
|--------------------------------------------------------------------------
| Domain Object Namespaces
| Custom Layers
|--------------------------------------------------------------------------
|
| This value contains the default namespaces of generated domain
| objects relative to the domain namespace of which the object
| belongs to.
| Additional top-level namespaces and paths that should be recognized as
| layers when generating ddd:* objects.
|
| e.g., Domain\Invoicing\Models\*
| Domain\Invoicing\Data\*
| Domain\Invoicing\ViewModels\*
| Domain\Invoicing\ValueObjects\*
| Domain\Invoicing\Actions\*
| e.g., 'Infrastructure' => 'src/Infrastructure',
|
*/
'layers' => [
'Infrastructure' => 'src/Infrastructure',
// 'Integrations' => 'src/Integrations',
// 'Support' => 'src/Support',
],

/*
|--------------------------------------------------------------------------
| Object Namespaces
|--------------------------------------------------------------------------
|
| This value contains the default namespaces of ddd:* generated
| objects relative to the layer of which the object belongs to.
|
*/
'namespaces' => [
Expand All @@ -48,6 +66,7 @@
'class' => '',
'channel' => 'Channels',
'command' => 'Commands',
'controller' => 'Controllers',
'enum' => 'Enums',
'event' => 'Events',
'exception' => 'Exceptions',
Expand All @@ -56,13 +75,17 @@
'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' => '',
],

Expand All @@ -71,12 +94,11 @@
| 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.
| The base model class which generated domain models should extend. If
| set to null, the generated models will extend Laravel's default.
|
*/
'base_model' => 'Domain\Shared\Models\BaseModel',
'base_model' => null,

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -120,34 +142,16 @@
| Autoloading
|--------------------------------------------------------------------------
|
| Configure whether domain providers, commands, policies, and factories
| should be auto-discovered and registered.
| Configure whether domain providers, commands, policies, factories,
| and migrations 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,
'migrations' => true,
],

/*
Expand Down
Loading

0 comments on commit 08a6ebb

Please sign in to comment.