gubler/color-doctrine

Allow the use of a gubler/color Color as Doctrine field type.

v4.0.0 2024-04-10 18:53 UTC

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.