ARTICLE AD BOX
I'm building a PHP application using Clean Architecture principles.
I need a Money value object in the Domain layer and I'm trying to understand what is considered best practice today.
There seem to be several possible approaches, each of which seems to have significant drawbacks:
Implement my own immutable Money value object with operations like add, subtract, multiply, etc.
This gives full control, but feels like reinventing something that is already a solved problem.Use an existing library (for example brick/money) directly inside the Domain layer.
This introduces a direct dependency on a third-party implementation inside the core domain.Hide a third-party library behind interfaces/adapters.
This avoids direct coupling, but may introduce unnecessary abstraction and boilerplate for a value object.Keep Money as a simple data holder and move arithmetic operations into separate services.
This can lead to an anemic domain model and scattered business rules.I'm trying to avoid unnecessary overengineering, but also don't want to reinvent the wheel if there is already a widely accepted approach.
P.S. The question is not only about Money, but also about other complex value objects with non-trivial behavior.
