gubler / color-doctrine
允许使用 gubler/color Color 作为 Doctrine 字段类型。
v4.0.0
2024-04-10 18:53 UTC
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-09-10 19:57:22 UTC
README
gubler/color-doctrine 包提供了使用 gubler/color 作为 Doctrine 字段类型 的能力。
安装
推荐的安装方法是通过 Packagist 和 Composer。运行以下命令来安装包并将其添加到项目的 composer.json 文件的要求中
composer require gubler/color-doctrine
示例
要配置 Doctrine 以使用 gubler/color 作为字段类型,您需要在您的 bootstrap 中设置以下内容
\Doctrine\DBAL\Types\Type::addType('color', 'Gubler\Color\Doctrine\ColorType');
在 Symfony 中
# app/config/config.yml doctrine: dbal: types: color: Gubler\Color\Doctrine\ColorType
然后,在您的模型中,您可以通过将 Column 属性类型设置为 color 来注释属性。Doctrine 将处理其余部分。
#[Entity] #[Table(name="label")] class label { #[Column(type="color")] private Color $color; public function getColor(): \Gubler\Color\Color { return $this->color; } }
更多信息
有关 Doctrine 入门的更多信息,请参阅 "[Getting Started with Doctrine][doctrine-getting-started]" 教程。
感谢
非常感谢 ramsey/uuid-doctrine。该项目基于该包。
版权和许可
gubler/color-doctrine 库版权 © Daryl Gubler,并许可在 MIT 许可证(MIT)下使用。请参阅 [LICENSE][] 获取更多信息。