定制 formal/orm 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

formal/orm

最新稳定版本:6.0.0

Composer 安装命令:

composer require formal/orm

包简介

README 文档

README

Build Status codecov Type Coverage

This ORM1 focuses to simplify data manipulation.

This is achieved by:

  • using immutable objects
  • each aggregate owning the objects it references
  • using monads to fetch aggregates (from the Innmind ecosystem)
  • using the specification pattern to match aggregates

This allows:

  • simpler app design (as it can be pure)
  • memory efficiency (the ORM doesn't keep objects in memory)
  • long living processes (since there is no memory leaks)
  • to work asynchronously

Installation

composer require formal/orm

Usage

use Formal\ORM\{
    Manager,
    Sort,
};
use Formal\AccessLayer\Connection\PDO;
use Innmind\Url\Url;

$manager = Manager::sql(
    PDO::of(Url::of('mysql://user:pwd@host:3306/database?charset=utf8mb4')),
);
$_ = $manager
    ->repository(YourAggregate::class)
    ->all()
    ->sort('someProperty', Sort::asc)
    ->drop(150)
    ->take(50)
    ->foreach(static fn($aggregate) => doStuff($aggregate));

This simple example will retrieve from the database 50 elements (from index 151 to 200) sorted by someProperty in ascending order and will call the function doStuff on each aggregate.

Note

The elements are streamed meaning only one aggregate is in memory at a time allowing you to deal with long lists of elements in a memory safe way.

Documentation

Full documentation available here.

Footnotes

  1. Object Relational Mapping

统计信息

  • 总下载量: 4.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 32
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 32
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-14