定制 artfocus/jetorm 二次开发

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

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

artfocus/jetorm

最新稳定版本:v3.6.2

Composer 安装命令:

composer require artfocus/jetorm

包简介

ORM for Nette\Database based on uestla\yetorm

README 文档

README

ATTENTION:

THIS PACKAGE IS NOT A THING YOU WANT TO WORK WITH.

PLEASE DO NOT USE IT IF YOU HAVE AN OPTION.

USE DOCTRINE 2 INSTEAD. REALLY. IT SAVES YOUR NERVES.

Artfocus\JetORM

Lightweight ORM built on top of Nette\Database. Based on uestla/yetorm, hranicka/yetorm. THANK YOU!

Quickstart

Consider following database schema:

Database schema

Installation

Setup config.neon like this:

extensions:
	jetorm: Artfocus\JetORM\Extension

yetorm:
	# setup cache IStorage for better performance
	# setup this only on production otherwise Entity doesn't load new Reflection until cache will be deleted!
	storage: cacheStorage # for development, leave this value empty (without "cacheStorage")

Entities

Firstly we'll create entity classes according to the schema above. There are two ways of defining entity properties - via @property[-read] annotation, or simply via getter and setter.

Tag

/**
 * @property-read int|null $id
 * @property string $name
 *
 * @method int|null getId()
 * @method string getName()
 *
 * @method Tag setName(string $name)
 */
class Tag extends Artfocus\JetORM\Entity
{
	
}

Author

/**
 * @property-read int|null $id
 * @property string $name
 * @property string $web
 * @property \DateTime $born
 *
 * @method int|null getId()
 * @method string getName()
 * @method string getWeb()
 * @method \DateTime getBorn()
 *
 * @method Author setName(string $name)
 * @method Author setWeb(string $web)
 * @method Author setBorn(\DateTime $born)
 */
class Author extends Artfocus\JetORM\Entity
{
	
}

Book

There are some relations at the Book entity - two N:1 Author and M:N Tag relations. Every Artfocus\JetORM\Entity has an instance of Artfocus\JetORM\Row in it, which is a simple wrapper around Nette\Database\Table\ActiveRow. That means that we can access related rows or column values through it.

/**
 * @property-read int|null $id
 * @property string $title
 * @property string $web
 * @property string $slogan
 * @property Author $author -> :one(author)
 * @property Author $maintainer -> :one(author, maintainer_id)
 * @property-read Tag[]|Artfocus\JetORM\Collection $tags -> :many(book_tag, tag)
 *
 * @method int|null getId()
 * @method string getTitle()
 * @method string getWeb()
 * @method string getSlogan()
 * @method Author getAuthor()
 * @method Author getMaintainer()
 * @method Tag[]|Artfocus\JetORM\Collection getTags()
 *
 * @method Book setTitle(string $title)
 * @method Book setWeb(string $web)
 * @method Book setSlogan(string $slogan)
 * @method Book setAuthor(Author $author)
 * @method Book setMaintainer(Author $maintainer)
 */
class Book extends Artfocus\JetORM\Entity
{

}

The M:N relation is realized with Artfocus\JetORM\Collection instance, default Artfocus\JetORM\EntityCollection - which is a lazy collection of entities.

Repositories

Every repository has to have table and entity class name defined - either via @table and @entity annotation, or via protected $table and $entity class property.

/**
 * @table book
 * @entity Book
 */
class BookRepository extends Artfocus\JetORM\Repository
{
	
}

Persisting

To persist changes we make simply call $repository->persist($entity).

$book->setWeb('http://example.com');
$books->persist($book);

And that's it!

Additional notes

  • No identity map
  • Query efficiency - the collections (resp. Artfocus\JetORM\Row) use the power of Nette\Database efficiency
  • Collection operations - collections can be sorted via $coll->orderBy($column, $dir) and limited via $coll->limit($limit, $offset)

More

For more examples please see the tests.

artfocus/jetorm 适用场景与选型建议

artfocus/jetorm 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.87k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 09 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「orm」 「nette」 「yetorm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 artfocus/jetorm 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 artfocus/jetorm 我们能提供哪些服务?
定制开发 / 二次开发

基于 artfocus/jetorm 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-15