dothiv/dothiv-valueobject-bundle
Symfony bundle providing a set of reusable value objects for Dothiv projects, aimed at consistent domain modeling and type-safe primitives. Includes common immutable objects and utilities to share across services and applications.
Money, Email, UUID). This fits well in Laravel applications where domain modeling and encapsulation are priorities.ValueObject base class, validation logic) is transferable.Money, Email) without requiring the full bundle. This reduces coupling and avoids Symfony2 dependencies.ParameterBag, Validator integration) may need Laravel alternatives (e.g., Illuminate\Support\MessageBag, Laravel’s built-in validation).symfony/validator, symfony/options-resolver) may conflict with Laravel’s ecosystem. Mitigation: Use standalone classes or composer aliases.Validator vs. Laravel’s native validation (though negligible for most use cases).Illuminate\Support\Carbon) or simple classes may suffice.use Dothiv\ValueObjectBundle\ValueObject; without Symfony).spatie/laravel-data (more Laravel-native).Money.php, Email.php) and use them directly in Laravel.
Validator with Laravel’s Validator::make() or custom logic.symfony/http-foundation for compatibility), but this adds complexity.Symfony\Component\Validator\Constraints with Laravel’s Illuminate\Validation\Rules.Money::class => Money::class).UserEmail, OrderTotal).Illuminate\Support\Str, Carbon).Email) and test in a Laravel controller/model.Validator.JsonSerializable).composer require for standalone classes or fork the repo to remove Symfony dependencies.| Feature | Symfony2 Bundle | Laravel Adaptation |
|---|---|---|
| Immutability | ✅ Yes | ✅ Yes (inherited) |
| Validation | ✅ Symfony Validator | ⚠️ Replace with Laravel Validator |
| Serialization | ✅ JMS Serializer | ✅ Laravel’s JsonSerializable |
| Dependency Injection | ✅ Symfony Container | ✅ Laravel Container |
| Testing | ✅ PHPUnit | ✅ PHPUnit (no changes) |
Email, Money) in a non-critical module.User properties like Email).User::email() returns Email instead of string).Email format).JsonSerializable is implemented for API responses.email + email_valid flags).| Risk | Impact | Mitigation |
|---|---|---|
| Package Abandonment | No future fixes | Fork or rewrite critical classes |
| Symfony Dependency Conflicts | Breaks Laravel integration | Use standalone classes |
| Validation Logic Errors | Invalid data slips through | Extensive unit/integration tests |
| Serialization Issues | API responses break | Implement JsonSerializable |
| Laravel Version Incompatibility | Adapters break | Test on target Laravel version |
// Before (mutable)
$email = "user@example.com";
// After (immutable)
$email = new Email("user@example.com"); // Throws on invalid format
How can I help you explore Laravel packages today?