upscale / doctrine-value-object-bundle
Symfony bundle for yokai/doctrine-value-object
Installs: 2 951
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 1
Forks: 1
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^8.1
- symfony/framework-bundle: ^6.1
- yokai/doctrine-value-object: ^0.0.3
README
This package wraps yokai/doctrine-value-object in a bundle to simplify its use in Symfony projects.
Features:
- Zero config setup
- Attribute annotation
Installation
Install via Composer as a dependency:
composer require upscale/doctrine-value-object-bundle
Usage
Attribute Annotation
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; // ... }
Type Naming
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; // ... }
Contributing
Pull Requests with fixes and improvements are welcome!
License
Copyright © Upscale Software. All rights reserved.
Licensed under the Apache License, Version 2.0.