Platine ORM 提供了一个灵活且强大的 ORM,实现了数据映射模式。

v1.0.0 2023-12-05 09:08 UTC

This package is auto-updated.

Last update: 2024-08-31 09:39:57 UTC


README

Platine ORM 提供了一个灵活且强大的 ORM,实现了数据映射模式。

Project Status Latest Stable Version Latest Unstable Version Total Downloads License
Tests Quality Score Codacy Badge Codacy Badge

要求

  • PHP >= 7.4, PHP 8

安装

使用 composer(推荐)

composer require platine-php/orm

许可证

MIT 许可证 查看 LICENSE.MD

资源

将 opis/orm 版本更改为 1.0.x-dev

Platine ORMopis/orm 获得灵感。以下记录了 opis/orm 的所有显著更改。

全局更改

  • 将代码更新到 PHP 7.4(类型属性、object 类型等。)
  • 在所有文件中添加 declare(strict_types=1);
  • 将所有命名空间 Opis\ORM 更改为 Platine\Orm
  • 添加接口 RepositoryInterface 和类 Repository
  • 将类 IEntityMapper, IDataMapper, EntityMapper, DataMapper, Proxy 移动到 Platine\Orm\Mapper
  • 将类 Query, EntityQuery 移动到 Platine\Orm\Query
  • 将接口 IEntityMapper 重命名为 EntityMapperInterface
  • 将接口 IDataMapper 重命名为 DataMapperInterface
  • 将接口 IMappableEntity 中的方法 mapEntity 移动到 Entity 类,并将其设置为抽象方法,以强制每个子类实现它
  • 移除接口 IMappableEntity
  • 将类 ForeignKey, PrimaryKey, Junction, Relation, RelationFactory, LazyLoader, BelongsTo, HasOneOrMany, ShareOneOrMany 移动到 Platine\Orm\Relation
  • 将类 LazyLoader 重命名为 RelationLoader
  • Platine\Orm\Relation 中添加新的抽象类 ShareRelation,以包含 ShareOneOrMany 的实现
  • Platine\Orm\Relation 中添加新的抽象类 HasRelation,以包含 HasOneOrMany 的实现
  • 将类 ShareOneOrMany 分解为两个类 ShareOneShareMany
  • 将类 HasOneOrMany 分解为两个类 HasOneHasMany
  • 在命名空间 Platine\Database\Exception 下添加异常包
  • 根据静态分析工具(phpstan)将所有类型提示数组更改为数组表示法,例如 array<int, string> 等。
  • 在每个类中,根据修饰符 public -> protected -> private 对所有方法进行排序
  • 将特质 LoaderTrait, SelectTrait, SoftDeletesTrait 的功能移动到 Query
  • 将特质 AggregateTrait 的功能移动到 EntityQuery

详细更改

类 EntityMapperInterface
  • 将方法 entityName 重命名为 name
  • 将方法 assignable 重命名为 fillable
  • 将方法 useSoftDelete 中参数 $column 的默认值设置为 deleted_at
  • 将方法 useTimestamp 中的参数 created_at 重命名为 createdAt
  • 将方法 useTimestamp 中的参数 updated_at 重命名为 updatedAt
类 EntityMapper
  • 将属性 entityName 重命名为 name
  • 将属性 assignable 重命名为 fillable
  • 将属性 softDelete 重命名为 useSoftDelete
  • 将属性 timestamp 重命名为 useTimestamp
  • 将方法 getEntityName 重命名为 getName
  • 将方法 getClass 重命名为 getEntityClass
  • 将方法 getTypeCasts 重命名为 getCasts
  • 将方法 supportsSoftDelete 重命名为 hasSoftDelete
  • 将方法 supportsTimestamp 重命名为 hasTimestamp
  • 将方法 getAssignableColumns 重命名为 getFillable
  • 将方法 getGuardedColumns 重命名为 getGuarded
  • 在方法 on 中增加使用多个事件处理器的可能性
类 Entity
  • 将方法 orm 重命名为 mapper
  • 添加魔法方法 __get, __set, __isset
类 PrimaryKey
  • 将方法 valueFromDataMapper 重命名为 getValueFromDataMapper
  • 将方法 valueFromEntity 重命名为 getValueFromEntity
类 Proxy
  • 将属性 ormMethod 重命名为 mapperMethod
  • 将方法 getDataMapper 重命名为 getEntityDataMapper
类 Relation
  • 将方法 getLazyLoader 重命名为 getLoader
类 DataMapperInterface
  • 将方法 assign 重命名为 fill
  • 将方法 stale 重命名为 refresh
  • 添加方法 hasColumnhasRelated
  • 移除方法 getRelated 的参数 $callback
类 DataMapper
  • 将方法 assign 重命名为 fill
  • 将方法 linkOrUnlink 重命名为 setLink
  • 将属性 stale 重命名为 refresh
类 EntityManager
  • 将方法 resolveEntityMapper 重命名为 getEntityMapper
类 Query
  • 将属性 have 重命名为 havingStatement
  • 将方法 onlySoftDeleted 重命名为 onlyDeleted
  • 将方法 withSoftDeleted 重命名为 withDeleted
类 EntityQuery
  • 将方法 getLazyLoaders 重命名为 getRelationLoaders
  • 移除方法 transaction 的参数 $default
类 EntityManager
  • 移除属性 entityMappingCallbackscompiler
  • 移除方法 __invoke, registerMappingCallback, getCompiler
  • 移除方法 __construct 的参数 $callbacks
  • 将方法 save, create, delete 移动到类 RepositoryInterface