Frames and DDD
You make the wrong assumption here, which is "I'm going to use the Symfony platform to implement my application using DDD-ish . "
Do not do this, the Framework is just detailed implementation information and provide one (more) delivery methods for the Application . And I mean the application here in the context of hexagonal architecture .
If you look at the following example from one of our contexts, you will see that our ApiClient context contains three levels (top-level directory structure). Application (contains usage services), Domain (contains models and behavior) and Infrastructure (contains infrastructure issues such as storage and delivery). I focused on integrating Symfony and persistence here, since this was a question of the original OP:
src/ApiClient ├── Application │ ├── ApiClient │ │ ├── CreateApiClient │ │ ├── DisableApiClient │ │ ├── EnableApiClient │ │ ├── GetApiClient │ │ ├── ListApiClient │ │ ├── RemoveApiClient │ │ └── ChangeApiClientDetails │ ├── ClientIpAddress │ │ ├── BlackListClientIpAddress │ │ ├── CreateClientIpAddress │ │ ├── ListByApiClientId │ │ ├── ListClientIpAddresses │ │ └── WhiteListClientIpAddress │ └── InternalContactPerson │ ├── CreateInternalContactPerson │ ├── GetInternalContactPerson │ ├── GetByApiClientId │ ├── ListContacts │ ├── ReassignApiClient │ └── Remove ├── Domain │ └── Model │ ├── ApiClient │ ├── ClientIpAddress │ └── InternalContactPerson └── Infrastructure ├── Delivery │ └── Http │ └── SymfonyBundle │ ├── Controller │ │ ├── ApiClientController.php │ │ ├── InternalContactController.php │ │ └── IpAddressController.php │ ├── DependencyInjection │ │ ├── Compiler │ │ │ ├── EntityManagerPass.php │ │ │ └── RouterPass.php │ │ ├── Configuration.php │ │ ├── MetadataLoader │ │ │ ├── Adapter │ │ │ │ ├── HateoasSerializerAdapter.php │ │ │ │ └── JMSSerializerBuilderAdapter.php │ │ │ ├── Exception │ │ │ │ ├── AmbiguousNamespacePathException.php │ │ │ │ ├── EmptyMetadataDirectoryException.php │ │ │ │ ├── FileException.php │ │ │ │ ├── MalformedNamespaceException.php │ │ │ │ └── MetadataLoadException.php │ │ │ ├── FileMetadataLoader.php │ │ │ ├── MetadataAware.php │ │ │ └── MetadataLoaderInterface.php │ │ └── MFBApiClientExtension.php │ ├── DTO │ │ └── ApiClient │ │ └── ChangeInternalContact │ │ ├── ChangeInternalContactRequest.php │ │ └── ChangeInternalContactResponse.php │ ├── MFBApiClientBundle.php │ ├── Resources │ │ ├── config │ │ │ ├── domain_services.yml │ │ │ ├── metadata_loader.yml │ │ │ ├── routing.yml │ │ │ └── services.yml │ │ ├── hateoas │ │ │ └── ApiClient │ │ │ ├── Application │ │ │ │ ├── ApiClient │ │ │ │ │ ├── CreateApiClient │ │ │ │ │ │ └── CreateApiClientResponse.yml │ │ │ │ │ └── ListApiClient │ │ │ │ │ └── ListApiClientResponse.yml │ │ │ │ ├── ClientIpAddress │ │ │ │ │ ├── CreateClientIpAddress │ │ │ │ │ │ └── CreateClientIpAddressResponse.yml │ │ │ │ │ ├── ListByApiClientId │ │ │ │ │ │ └── ListByApiClientIdResponse.yml │ │ │ │ │ └── ListClientIpAddresses │ │ │ │ │ └── ListClientIpAddressesResponse.yml │ │ │ │ └── InternalContactPerson │ │ │ │ ├── Create │ │ │ │ │ └── CreateResponse.yml │ │ │ │ └── List │ │ │ │ └── ListResponse.yml │ │ │ └── Domain │ │ │ ├── ApiClient │ │ │ │ └── ApiClient.yml │ │ │ ├── ClientIpAddress │ │ │ │ └── ClientIpAddress.yml │ │ │ └── InternalContactPerson │ │ │ └── InternalContactPerson.yml │ │ └── serializer │ │ ├── ApiClient │ │ │ ├── Application │ │ │ │ ├── ApiClient │ │ │ │ │ ├── CreateApiClient │ │ │ │ │ │ ├── ContactPersonRequest.yml │ │ │ │ │ │ ├── CreateApiClientRequest.yml │ │ │ │ │ │ └── CreateApiClientResponse.yml │ │ │ │ │ └── GetApiClient │ │ │ │ │ └── GetApiClientResponse.yml │ │ │ │ ├── ClientIpAddress │ │ │ │ │ └── CreateClientIpAddress │ │ │ │ │ ├── CreateClientIpAddressRequest.yml │ │ │ │ │ └── CreateClientIpAddressResponse.yml │ │ │ │ └── InternalContactPerson │ │ │ │ ├── Create │ │ │ │ │ ├── CreateRequest.yml │ │ │ │ │ └── CreateResponse.yml │ │ │ │ ├── Get │ │ │ │ │ └── GetResponse.yml │ │ │ │ ├── List │ │ │ │ │ └── ListResponse.yml │ │ │ │ └── ReassignApiClient │ │ │ │ └── ReassignApiClientRequest.yml │ │ │ └── Domain │ │ │ ├── ApiClient │ │ │ │ ├── ApiClient.yml │ │ │ │ └── ContactPerson.yml │ │ │ ├── ClientIpAddress │ │ │ │ └── ClientIpAddress.yml │ │ │ └── InternalContactPerson │ │ │ └── InternalContactPerson.yml │ │ └── Bundle │ │ └── DTO │ │ └── ApiClient │ │ └── ChangeInternalContact │ │ └── ChangeInternalContactRequest.yml │ └── Service │ └── Hateoas │ └── UrlGenerator.php └── Persistence ├── Doctrine │ ├── ApiClient │ │ ├── ApiClientRepository.php │ │ └── mapping │ │ ├── ApiClientId.orm.yml │ │ ├── ApiClient.orm.yml │ │ ├── CompanyName.orm.yml │ │ ├── ContactEmail.orm.yml │ │ ├── ContactList.orm.yml │ │ ├── ContactName.orm.yml │ │ ├── ContactPerson.orm.yml │ │ ├── ContactPhone.orm.yml │ │ └── ContractReference.orm.yml │ ├── ClientIpAddress │ │ ├── ClientIpAddressRepository.php │ │ └── mapping │ │ ├── ClientIpAddressId.orm.yml │ │ ├── ClientIpAddress.orm.yml │ │ └── IpAddress.orm.yml │ └── InternalContactPerson │ ├── InternalContactPersonRepository.php │ └── mapping │ ├── InternalContactPersonId.orm.yml │ └── InternalContactPerson.orm.yml └── InMemory ├── ApiClient │ └── ApiClientRepository.php ├── ClientIpAddress │ └── ClientIpAddressRepository.php └── InternalContactPerson └── InternalContactPersonRepository.php 94 directories, 145 files
Quite a lot of files!
You can see that I use the package as a port for the application (although the naming is small, it should not be Http delivery, because in the strict sense, the Hexagon architecture is the application port for the application ). I highly recommend you read DDD in a PHP book , where all these concepts are actually explained by expressive examples in PHP (if you read the blue book and the red book, although this book works autonomously while still making links).
source share