kayladnls / doctrine-additions
额外的 Doctrine 类型和小助手
0.2.0
2016-05-02 14:28 UTC
Requires
- php: >=5.5
Requires (Dev)
- doctrine/orm: ^2.5
- league/uri: ^4.1.1
- phpunit/phpunit: >=4.8
Suggests
- league/uri: For use with the UrlType
This package is not auto-updated.
Last update: 2024-09-18 19:14:13 UTC
README
这个库为 Doctrine 2 提供了一个基于 league/url
的自定义 UrlType
。
有关自定义 doctrine 类型的更多信息,请参见 这里。
使用方法
在 Bootstrap 文件中
use Doctrine\DBAL\Types\Type;
Type::addType('url', Kayladnls\DoctrineAdditions\Type\UrlType::class);
将类型注册到您的连接中
$conn = $em->getConnection();
$conn->getDatabasePlatform()->registerDoctrineTypeMapping('varchar', 'url');
在实体中使用此类型
class MyEntity
{
/** @Column(type="url") */
private $link;
}