Closed
Description
In order to make it easier for users to adopt DDD, it would be great to provide custom Makers to generate boilerplate code and organize code in a more DDD-preferred/conform way.
Some ideas:
MakeModel
- Lives in
src/Domain/Model
- Can inherit from
AggregateRoot
- Can have a dedicated identity value object (e.g.
Order
→OrderId
/OrderUuid
) - If also used as Doctrine entity, choice between annotations and separate config in
src/Infrastructure/Doctrine/ORM/config
- If used with annotations, the Doctrine config must be updated to accommodate for the custom path
MakeRepsitory
- Lives (as interface) in
src/Domain/Repository
- Extends the
Repository
contract fromgeekcell/php-ddd
- Can have a Doctrine implementation, which lives in
src/Infrastructure/Doctrine/ORM/Repository
- Inherits from
GeekCell\DddBundle\Infrastructure\Doctrine\Repository
- Parent constructor needs to know about the managed entity
- Inherits from
MakeCommand
/ MakeQuery
- Lives in
src/Application/{Command,Query}
- Implements the
Command
/Query
contract fromgeekcell/ddd
- Has a corresponding command/query handler
- Same name as command/query with
Handler
suffix - Implements the
CommandHandler
/QueryHandler
contract fromgeekcell/ddd
- Has a
#[AsMessageHandler]
annotation - Has a
__invoke
method with the corresponding command/query as argument
- Same name as command/query with
MakeResource
- API Platform resource (> 2.7)
- Lives in
src/Infrasturcture/ApiPlatform/Resource
- Has a corresponding model (e.g.
Order
→OrderResource
) - The resource has a convenience method
public static fromModel(...)
- Choice between annotations or separate config
config/packages/api_platform.yaml
needs to be updated with the custom resource path- Can have one or more data provider (read operations) which live in
src/Infrasturcture/ApiPlatform/State
- Has a query bus
- Can have one or more data processors (write operations) which live in
src/Infrasturcture/ApiPlatform/State
- Has a command bus
MakeController
- Lives in
src/Infrastructure/Http/Controller
- Can have a command bus, a query bus, or both
- Other than that → standard Symfony configuration
### Makers to implement
- [x] Add Maker for domain models (`MakeModel`) https://github.com/geekcell/ddd-symfony-bundle/pull/14
- [x] Add Maker for repositories (`MakeRepository`) https://github.com/geekcell/ddd-symfony-bundle/pull/14
- [x] Add Maker for commands and queries (`MakeCommand`, `MakeQuery`) https://github.com/geekcell/ddd-symfony-bundle/pull/21
- [x] Add Maker for API Platform resources (`MakeResource`) https://github.com/geekcell/ddd-symfony-bundle/pull/25
- [x] Add Maker for controllers `MakeController`) https://github.com/geekcell/ddd-symfony-bundle/pull/22