This package wraps yokai/doctrine-value-object in a bundle to simplify its use in Symfony projects.
Features:
- Zero config setup
- Attribute annotation
Install via Composer as a dependency:
composer require upscale/doctrine-value-object-bundle
Register a value object using an attribute annotation (available since PHP 8):
use Upscale\DoctrineValueObjectBundle\Attribute\ValueObject;
use Yokai\DoctrineValueObject\StringValueObject;
#[ValueObject]
class PhoneNumber implements StringValueObject {...}
Reference the value object type by an underscore separated short class name:
#[Entity]
class Person
{
#[Column(type: 'phone_number')]
private PhoneNumber $phone;
// ...
}
You can customize the type name, including use a fully-qualified class name, for example:
#[ValueObject(type: PhoneNumber::class)]
class PhoneNumber implements StringValueObject {...}
#[Entity]
class Person
{
#[Column(type: PhoneNumber::class)]
private PhoneNumber $phone;
// ...
}
Pull Requests with fixes and improvements are welcome!
Copyright © Upscale Software. All rights reserved.
Licensed under the Apache License, Version 2.0.