You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a design-related question, As I know about DDD and some sources I read, most people indicate separations between domain and persistence (or infrastructure in general). Most people use Doctrine ORM when they consider the DDD approach in PHP, domain models (or Entities) are a part of domain, so they have no idea about persistence.
Let's imagine we have an Author domain model that publishes posts, I thought below code:
class Post
{
publicfunction__construct(
protectedAuthor$author,
protectedPostTitle$title,
protectedPostContent$content,
protectedDateTimeImmutable$publishedAt
) {}
}
class Author
{
publicfunction__construct(
protectedAuthorEmail$email,
protectedarray$posts = []
) {}
publicfunctionpublishNewPost(Post$post)
{
$this->posts []= $posts;
}
}
I fact, what I want is I could use the Post and Author classes as domain models without any persistence concern (doctrine annotations/ArrayCollection class/...). I'd like to separate Doctrine's entity from domain models and I don't know what should I do. Could you help me, please?
The text was updated successfully, but these errors were encountered:
Hi,
I have a design-related question, As I know about DDD and some sources I read, most people indicate separations between domain and persistence (or infrastructure in general). Most people use Doctrine ORM when they consider the DDD approach in PHP, domain models (or Entities) are a part of domain, so they have no idea about persistence.
Let's imagine we have an
Author
domain model that publishesposts
, I thought below code:I fact, what I want is I could use the
Post
andAuthor
classes as domain models without any persistence concern (doctrine annotations/ArrayCollection class/...). I'd like to separate Doctrine's entity from domain models and I don't know what should I do. Could you help me, please?The text was updated successfully, but these errors were encountered: