gubler / color-doctrine
Allow the use of a gubler/color Color as Doctrine field type.
Requires
- php: ^8.2
- doctrine/orm: ^2.9|^3.0
- gubler/color: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.53
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.10
- phpstan/phpstan-doctrine: ^1.3
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^11.1
- rector/rector: ^1.0
- symfony/var-dumper: ^7.0
- tomasvotruba/type-coverage: ^0.2
This package is auto-updated.
Last update: 2024-11-10 20:21:23 UTC
README
The gubler/color-doctrine package provides the ability to use gubler/color as a Doctrine field type.
Installation
The preferred method of installation is via Packagist and Composer. Run
the following command to install the package and add it as a requirement to
your project's composer.json
:
composer require gubler/color-doctrine
Examples
To configure Doctrine to use gubler/color as a field type, you'll need to set up the following in your bootstrap:
\Doctrine\DBAL\Types\Type::addType('color', 'Gubler\Color\Doctrine\ColorType');
In Symfony:
# app/config/config.yml doctrine: dbal: types: color: Gubler\Color\Doctrine\ColorType
Then, in your models, you may annotate properties by setting the Column
attribute
type to color
. Doctrine will handle the rest.
#[Entity] #[Table(name="label")] class label { #[Column(type="color")] private Color $color; public function getColor(): \Gubler\Color\Color { return $this->color; } }
More Information
For more information on getting started with Doctrine, check out the "[Getting Started with Doctrine][doctrine-getting-started]" tutorial.
Thanks
Huge thanks to ramsey/uuid-doctrine. This project is based off of that package.
Copyright and License
The gubler/color-doctrine library is copyright © Daryl Gubler and licensed for use under the MIT License (MIT). Please see [LICENSE][] for more information.