laravel-doctrine / fluent
Doctrine2 的流畅 PHP 映射驱动器。
1.3.2
2024-01-10 07:46 UTC
Requires
- php: ^7.2|^8.0
- doctrine/dbal: ^2.10|^3.3
- doctrine/inflector: ^1.4|^2.0
- doctrine/orm: ^2.6
- doctrine/persistence: ^1.3.5|^2.0|^3.0
Requires (Dev)
- beberlei/doctrineextensions: ~1.0
- gedmo/doctrine-extensions: ^2.4|^3
- mockery/mockery: ~1.0
- nesbot/carbon: *
- phpunit/phpunit: ~8.0|~9.0
- zf1/zend-date: ~1.12
README
Doctrine2 的流畅映射驱动器
composer require laravel-doctrine/fluent
此映射驱动器允许您以面向对象的方式管理映射,将实体与映射配置分离,无需使用 XML 或 YAML 等配置文件。这是通过实现 LaravelDoctrine\Fluent\Mapping
接口或扩展此包中提供的抽象类来实现的,以便更容易使用:LaravelDoctrine\Fluent\EntityMapping
、LaravelDoctrine\Fluent\EmbeddableMapping
或 MappedSuperClassMapping
。
此包提供了一个流畅的构建器,用于 Doctrine 的 ClassMetadataBuilder
,旨在简化 Laravel 中 Doctrine 映射概念的使用。构建器添加了语法糖,并实现了您可能在 Laravel 迁移中使用的相同语法。
class ScientistMapping extends EntityMapping { /** * Returns the fully qualified name of the class that this mapper maps. * * @return string */ public function mapFor() { return Scientist::class; } /** * Load the object's metadata through the Metadata Builder object. * * @param Fluent $builder */ public function map(Fluent $builder) { $builder->increments('id'); $builder->embed(Name::class, 'name'); $builder->hasMany(Theory::class, 'theories')->ownedBy('scientist'); } }