Releases: lunarstorm/laravel-ddd
v1.2.0
🔥 1.2 is a major update with several new features and breaking changes (for some). Use php artisan ddd:config update
to rebuild your existing config file according to the latest version, and be sure to review the Upgrade Guide for full details about upgrading from 1.1.x.
[1.2.0] - 2024-11-23
Breaking
- Stubs are now published to
base_path('stubs/ddd')
instead ofresource_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:
// 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.:// 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 applicationdatabase/migrations
path. - Ability to customize generator object naming conventions with your own logic using
DDD::resolveObjectSchemaUsing()
.
Changed
ddd:model
now extends Laravel's nativemake: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 nowddd:optimize
(ddd:cache
is still available as an alias).- Since Laravel 11.27.1, the framework's
optimize
andoptimize:clear
commands will automatically invokeddd:optimize
(ddd:cache
) andddd:clear
respectively.
Deprecated
- Domain base models are no longer required by default, and
config('ddd.base_model')
is nownull
by default. - Stubs are no longer published via
php artisan vendor:publish --tag="ddd-stubs"
. Instead, usephp artisan ddd:stub
to manage them.
What's Changed
- [1.2] Official Release by @JasperTey in #77
- Release 1.2 by @JasperTey in #81
Full Changelog: v1.1.3...v1.2.0
v1.2.0-beta.3
The final v1.2.0 pre-release, which adds support for custom layers (e.g., Infrastructure), finalizes the config conventions, adds a ddd:config utility command, and more.
To use this version now:
composer require lunarstorm/laravel-ddd:dev-next
Full 1.2.0 Changelog:
Upgrade guide: https://github.com/lunarstorm/laravel-ddd/blob/next/UPGRADING.md
Breaking
- Stubs are now published to
base_path('stubs/ddd')
instead ofresource_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:
// 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.:// 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 applicationdatabase/migrations
path. - Ability to customize generator object naming conventions with your own logic using
DDD::resolveObjectSchemaUsing()
.
Changed
ddd:model
now extends Laravel's nativemake: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 nowddd:optimize
(ddd:cache
is still available as an alias).- Since Laravel 11.27.1, the framework's
optimize
andoptimize:clear
commands will automatically invokeddd:optimize
(ddd:cache
) andddd:clear
respectively.
Deprecated
- Domain base models are no longer required by default, and
config('ddd.base_model')
is nownull
by default. - Stubs are no longer published via
php artisan vendor:publish --tag="ddd-stubs"
. Instead, usephp artisan ddd:stub
to manage them.
What's Changed
- [1.2] Custom Layers by @JasperTey in #76
Full Changelog: v1.2.0-beta.2...v1.2.0-beta.3
v1.2.0-beta.2
A second v1.2.0 pre-release, which refactors the customization of stubs and introduces a more user friendly ddd:stub
command to publish one or more stubs selectively. To use this version now:
composer require lunarstorm/laravel-ddd:dev-next
Full summary of changes from v1.1.x below.
Breaking
- Stubs are now published to
base_path('stubs/ddd')
instead ofresource_path('stubs/ddd')
. In other words, they are now co-located alongside the framework's published stubs, within addd
subfolder. - Normalize published stubs to use
.stub
extension instead of.php.stub
(following Laravel's convention).
Added
- Ability to configure the Application Layer, to generate domain objects that don't typically belong inside the domain layer.
// In config/ddd.php 'application' => [ 'path' => 'app/Modules', 'namespace' => 'App\Modules', 'objects' => [ 'controller', 'request', 'middleware', ], ],
- Added
ddd:controller
to generate domain-specific controllers in the application layer. - Added
ddd:request
to generate domain-spefic requests in the application layer. - Added
ddd:middleware
to generate domain-specific middleware in the application layer. - Added
ddd:migration
to generate domain migrations. - Added
ddd:seeder
to generate domain seeders. - Added
ddd:publish
to publish the config or stubs in a more user friendly manner. - Added
ddd:stub
to list, search, and publish one or more stubs as needed. - Migration folders across domains will be registered and scanned when running
php artisan migrate
, in addition to the standard applicationdatabase/migrations
path.
Changed
ddd:model
now internally extends Laravel's nativemake: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 nowddd:optimize
(ddd:cache
is still available as an alias).- For Laravel 11.27.1+, the framework's
optimize
andoptimize:clear
commands will automatically invokeddd:optimize
andddd:clear
respectively. - Normalize stubs to use
.stub
extension instead of.php.stub
(following Laravel's convention). - For ddd:* generators that inherit Laravel's stubs, custom stubs will be resolved as follows:
- Try
stubs/ddd/*.stub
(allows customizing stub for ddd only) - Try
stubs/*.stub
(shared by both make:* and ddd:*) - Fallback to the framework or package default
- Try
Deprecated
- Domain base models are no longer required by default, and
config('ddd.base_model')
is nownull
by default. - Removed ddd-specific model stub, now that
ddd:model
extends laravel'smake:model
and therefore inherits the native stubs.
What's Changed
- [1.2] ddd:model options, migrations, application layer by @JasperTey in #69
- [1.2] Refactoring stubs by @JasperTey in #71
Full Changelog: v1.1.3...v1.2.0-beta.2
v1.1.3
[1.1.3] - 2024-11-05
Chore
- Allow
laravel/prompts
dependency to use latest version when possible.
What's Changed
- Bump laravel prompts dependency. by @JasperTey in #74
Full Changelog: v1.1.2...v1.1.3
v1.2.0-beta.1
There are still a few things to iron out before a final 1.2.0 release, but I wanted to get this out as a pre-release for now to keep things moving.
Added
- Experimental: Ability to configure the Application Layer, to generate domain objects that don't typically belong inside the domain layer.
// In config/ddd.php 'application' => [ 'path' => 'app/Modules', 'namespace' => 'App\Modules', 'objects' => [ 'controller', 'request', 'middleware', ], ],
- Added
ddd:controller
to generate domain-specific controllers in the application layer. - Added
ddd:request
to generate domain-spefic requests in the application layer. - Added
ddd:middleware
to generate domain-specific middleware in the application layer. - Added
ddd:migration
to generate domain migrations. - Added
ddd:seeder
to generate domain seeders. - Migration folders across domains will be registered and scanned when running
php artisan migrate
, in addition to the standard applicationdatabase/migrations
path.
Changed
ddd:model
now internally extends Laravel's nativemake: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 nowddd:optimize
(ddd:cache
is still available as an alias).- For Laravel 11.27.1+, the framework's
optimize
andoptimize:clear
commands will automatically invokeddd:optimize
andddd:clear
respectively.
Deprecated
- Domain base models are no longer required by default, and
config('ddd.base_model')
is nownull
by default.
What's Changed
- [1.2] ddd:model options, migrations, application layer by @JasperTey in #69
Full Changelog: v1.1.2...v1.2.0-beta.1
v1.1.2
[1.1.2] - 2024-09-02
Fixed
- During domain factory autoloading, ensure that
guessFactoryNamesUsing
returns a string when a domain factory is resolved. - Resolve issues with failing tests caused by mutations to
composer.json
that weren't rolled back.
What's Changed
- Bump dependabot/fetch-metadata from 2.0.0 to 2.1.0 by @dependabot in #59
- Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in #63
- Resolve get class string instead of an object. by @PhilippeThouvenot in #64
- Fix tests by @JasperTey in #65
- Release 1.1.2 by @JasperTey in #66
New Contributors
- @PhilippeThouvenot made their first contribution in #64
Full Changelog: v1.1.1...v1.1.2
v1.1.1
[1.1.1] - 2024-04-17
Added
- Ability to ignore folders during autoloading via
config('ddd.autoload_ignore')
, or register a custom filter callback viaDDD::filterAutoloadPathsUsing(callable $filter)
.
/*
|--------------------------------------------------------------------------
| 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 `DDD::filterAutoloadPathsUsing(callback $filter)` in
| the AppServiceProvider's boot method.
|
*/
'autoload_ignore' => [
'Tests',
'Database/Migrations',
],
Changed
- Internals: Domain cache is no longer quietly cleared on laravel's
cache:clearing
event, so thatddd:cache
yields consistent results no matter which order it runs in production (before or aftercache:clear
oroptimize:clear
commands).
What's Changed
- Bump aglipanci/laravel-pint-action from 2.3.1 to 2.4 by @dependabot in #57
- 56 autoloading enhancements by @JasperTey in #58
Full Changelog: v1.1.0...v1.1.1
v1.1.0
[1.1.0] - 2024-04-07
Added
- Add
ddd:class
generator extending Laravel'smake:class
(Laravel 11 only). - Add
ddd:interface
generator extending Laravel'smake:interface
(Laravel 11 only). - Add
ddd:trait
generator extending Laravel'smake:trait
(Laravel 11 only). - Allow overriding configured namespaces at runtime by specifying an absolute name starting with /:
# 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
Fixed
- Internals: Handle a variety of additional edge cases when generating base models and base view models.
What's Changed
- 54 additional laravel 11 generators by @JasperTey in #55
Full Changelog: v1.0.0...v1.1.0
v1.0.0
v1 Highlights 🚀
Updated command syntax, 16 new generator commands, and support for autoloading and auto-discovery (domain service providers, commands, policies, factories). Minimum supported Laravel version is now 10.25.
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.
- In production,
ddd:cache
should be run during the deployment process to optimize autoloading. See the Autoloading in Production section for more details.
Full change details below.
[1.0.0] - 2024-03-31
Added
ddd:list
to show a summary of current domains in the domain folder.- For all generator commands, if a domain isn't specified, prompt for it with auto-completion suggestions based on the contents of the root domain folder.
- Command aliases for some generators:
- Data Transfer Object:
ddd:dto
,ddd:data
,ddd:data-transfer-object
,ddd:datatransferobject
- Value Object:
ddd:value
,ddd:valueobject
,ddd:value-object
- View Model:
ddd:view-model
,ddd:viewmodel
- Data Transfer Object:
- Additional generators that extend Laravel's generators and funnel the generated objects into the domain layer:
ddd:cast {domain}:{name}
ddd:channel {domain}:{name}
ddd:command {domain}:{name}
ddd:enum {domain}:{name}
(Laravel 11 only)ddd:event {domain}:{name}
ddd:exception {domain}:{name}
ddd:job {domain}:{name}
ddd:listener {domain}:{name}
ddd:mail {domain}:{name}
ddd:notification {domain}:{name}
ddd:observer {domain}:{name}
ddd:policy {domain}:{name}
ddd:provider {domain}:{name}
ddd:resource {domain}:{name}
ddd:rule {domain}:{name}
ddd:scope {domain}:{name}
- Support for autoloading and discovery of domain service providers, commands, policies, and factories. (co-authored by @pelmered)
Changed
- (BREAKING) For applications that published the config prior to this release, config should be removed, re-published, and re-configured.
- (BREAKING) Generator commands no longer receive a domain argument. 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). - Shorthand syntax:
ddd:action Invoicing:CreateInvoice
. - Or simply
ddd:action CreateInvoice
to be prompted for the domain afterwards.
- Using the --domain option:
- Improved the reliability of generating base view models when
ddd.base_view_model
is something other than the defaultDomain\Shared\ViewModels\ViewModel
. - Domain factories are now generated inside the domain layer under the configured factory namespace
ddd.namespaces.factory
(defaultDatabase\Factories
). Factories located in/database/factories/<domain>/*
(v0.x) will continue to work as a fallback when attempting to resolve a domain model's factory. - Minimum supported Laravel version is now 10.25.
Chore
- Dropped Laravel 9 support.
What's Changed
- Bump dependabot/fetch-metadata from 1.6.0 to 2.0.0 by @dependabot in #47
- v1.0 by @JasperTey in #46
New Contributors
Full Changelog: v0.10.0...v1.0.0
v0.10.0
[0.10.0] - 2024-03-23
Added
- Add
ddd.domain_path
andddd.domain_namespace
to config, to specify the path to the domain layer and root domain namespace more explicitly (replaces the previousddd.paths.domains
config). - Implement
Lunarstorm\LaravelDDD\Factories\HasDomainFactory
trait which can be used on domain models that are unable to extend the base domain model.
Changed
- Default
base-model.php.stub
now utilizes theHasDomainFactory
trait.
Deprecated
- Config
ddd.paths.domains
deprecated in favour ofddd.domain_path
andddd.domain_namespace
. Existing config files published prior to this release should removeddd.paths.domains
and addddd.domain_path
andddd.domain_namespace
accordingly.
/*
|--------------------------------------------------------------------------
| 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',
// Deprecated:
// 'paths' => [
// //
// // Path to the Domain layer.
// //
// 'domains' => 'src/Domain',
// ],
What's Changed
- Refactor domain path and namespace configuration. by @JasperTey in #43
- HasDomainFactory trait implementation. by @JasperTey in #44
Full Changelog: v0.9.0...v0.10.0