Cycle ORM 是PHP DataMapper,ORM和数据建模引擎

PHP DataMapper,ORM和数据建模引擎,旨在安全地在经典的守护进程PHP应用程序(如RoadRunner)中工作。 ORM提供了灵活的配置选项来建模数据集,强大的查询生成器并支持动态映射架构。 该引擎可以使用普通的PHP对象,支持注释声明和通过扩展的代理。

PHP 开发框架

访问GitHub主页

共734Star

详细介绍

Cycle ORM

Latest Stable Version Build Status Scrutinizer Code Quality Codecov

Cycle ORM

Cycle is PHP DataMapper, ORM and Data Modelling engine designed to safely work in classic and daemonized PHP applications (like RoadRunner). The ORM provides flexible configuration options to model datasets, powerful query builder and supports dynamic mapping schema. The engine can work with plain PHP objects, support annotation declarations, and proxies via extensions.

Website and Documentation | Comparison with Eloquent and Doctrine

Features:

  • clean and fast Data Mapper
  • ORM with has-one, has-many, many-through-many and polymorphic relations
  • Plain Old PHP objects, ActiveRecord, Custom objects or same entity type for multiple repositories
  • eager and lazy loading, query builder with multiple fetch strategies
  • embedded entities, lazy/eager loaded embedded partials
  • runtime configuration with/without code-generation
  • column-to-field mapping, single table inheritance, value objects support
  • hackable: persist strategies, mappers, relations, transactions
  • works with directed graphs and cyclic graphs using command chains
  • designed to work in long-running applications: immutable service core, disposable UoW
  • supports MySQL, MariaDB, PostgresSQL, SQLServer, SQLite
  • schema scaffolding, introspection, and migrations
  • supports global query constrains, UUIDs as PK, soft deletes, auto timestamps
  • custom column types, FKs to non-primary columns
  • use with or without annotations, proxy classes, and auto-migrations
  • compatible with Doctrine Collections, Doctrine Annotations, and Zend Hydrator

Extensions:

Component Current Status
cycle/schema-builder Latest Stable Version Build Status Scrutinizer Code Quality Codecov
cycle/annotated Latest Stable Version Build Status Scrutinizer Code Quality Codecov
cycle/proxy-factory Latest Stable Version Build Status Scrutinizer Code Quality Codecov
cycle/migrations Latest Stable Version Build Status Scrutinizer Code Quality Codecov

Example:

// load all active users and pre-load their paid orders sorted from newest to olders
// the pre-load will be complete using LEFT JOIN
$users = $orm->getRepository(User::class)
    ->select()
    ->where('active', true)
    ->load('orders', [
        'method' => Select::SINGLE_QUERY,
        'load'   => function($q) {
            $q->where('paid', true)->orderBy('timeCreated', 'DESC');
        }
    ])
    ->fetchAll();

$t = new Transaction($orm);

foreach($users as $user) {
    $t->persist($user);
}

$t->run();

License:

The MIT License (MIT). Please see LICENSE for more information. Maintained by Spiral Scout.