dddshelf / ddd-in-php-book-issues

Leave your comments, improvements or book mistakes as an issue! Thanks ❤️
https://leanpub.com/ddd-in-php
28 stars 2 forks source link

Project Structure for Shared Value Objects #67

Closed dewey92 closed 7 years ago

dewey92 commented 7 years ago

The book suggests to structure a project based on Bounded Contexts, where each has 3 main folders: Application, Domain, and Infrastructure. Models, services, value objects, all go to Domain folder. But sometimes in reality, we have to deal with shared Value Objects like Url. I use Url value object both in \Blog\Domain\Model\Article::getOriginalArticleUrl() and \Author\Domain\Model\Author::personalBlogUrl() and I can't figure out where this value object would belong to: is it in Blog or Author? Or I have to make a module named Shared?

I guess it would be so nice to go for an example in such situation 🙂

carlosbuenosvinos commented 7 years ago

Hi @dewey92, you can put the Url VO in /Domain/Model/Url/Url.php, for example. Or even in /Domain/Model/Url.php if you want to. I do not recommend to create a "Shared" folder.