PHPackages                             rayswoole/think-orm - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. rayswoole/think-orm

ActiveLibrary[Database &amp; ORM](/categories/database)

rayswoole/think-orm
===================

think-orm协程化版本, 仅在swoole协程环境使用

2.2.59(3y ago)2160Apache-2.0PHPPHP &gt;=7.1.0

Since Aug 11Pushed 3y agoCompare

[ Source](https://github.com/rayswoole/think-orm)[ Packagist](https://packagist.org/packages/rayswoole/think-orm)[ RSS](/packages/rayswoole-think-orm/feed)WikiDiscussions 2.0 Synced 3w ago

READMEChangelog (10)Dependencies (3)Versions (16)Used By (0)

RaySwooleORM
============

[](#rayswooleorm)

> fork in ThinkORM

基于PHP7.1+ 和PDO实现的ORM，支持多数据库，2.0版本主要特性包括：

- 基于PDO和PHP强类型实现
- 支持原生查询和查询构造器
- 自动参数绑定和预查询
- 简洁易用的查询功能
- 强大灵活的模型用法
- 支持预载入关联查询和延迟关联查询
- 支持多数据库及动态切换
- 支持`MongoDb`
- 支持分布式及事务
- 支持断点重连
- 支持`JSON`查询
- 支持数据库日志
- 支持`PSR-16`缓存及`PSR-3`日志规范

安装
--

[](#安装)

```
composer require rayswoole/think-orm

```

文档
--

[](#文档)

### 连接池配置

[](#连接池配置)

```
可以在onStart直接配置
每个worker进程都会生成同等配置的进程池, 请根据worker数量动态调整

```

```
//初始化连接配置
$dbConfig = new \rayswoole\orm\pool\DbPoolConfig();
//设置最小连接数
$dbConfig->withMin(5);
//设置最大连接数
$dbConfig->withMax(20);
//设置定时器执行频率(毫秒),创建最小进程、回收空闲进程
$dbConfig->withIntervalTime(15*1000)
//设置连接可空闲时间
$dbConfig->withIdleTime(10)
//获取连接池对象超时时间, 如果连接池占满在指定时间无法释放新的连接, 将输出Exception, 需要自行捕获
$dbConfig->withTimeout(3.0)

//数据库配置, 参考https://www.kancloud.cn/manual/think-orm/1257999
$dbConfig->withExtraConf('数据库数组结构')

//初始化连接池
\rayswoole\orm\facade\Db::init($dbConfig);

//可设置项
//设置log日志，必须继承Psr\Log\LoggerInterface接口(orm自带)
Db::setLog($Logger);
//设置缓存，用于ORM连贯操作`$Db->cache()`，必须继承Psr\SimpleCache\CacheInterface接口
Db::setCache($Cache);
```

### 使用

[](#使用)

```
use rayswoole\orm\facade
// table方法必须指定完整的数据表名
Db::table('think_user')->where('id', 1)->find();
// 如果设置了数据表前缀（prefix）参数的话 也可以使用
Db::name('user')->where('id', 1)->find();

//注意: 非协程环境使用必须主动释放连接（协程环境内会自动释放）
Db::close();

// 模型写法
use rayswoole\orm
class userModel extends Model{
    protected $name = 'test'; //指定数据库,不指定会自动设置为test_model
}
$model = new userModel();
$model->where('id', 1)->find();
```

具体语法详细参考 [ThinkORM开发指南](https://www.kancloud.cn/manual/think-orm/content)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~184 days

Total

16

Last Release

1212d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7fe37afe70c3655d3b66c7e6c2462056f93f58dc3a0730cafd97921044d1343?d=identicon)[haoguangyun](/maintainers/haoguangyun)

---

Top Contributors

[![liu21st](https://avatars.githubusercontent.com/u/1111670?v=4)](https://github.com/liu21st "liu21st (286 commits)")[![rayswoole](https://avatars.githubusercontent.com/u/69523714?v=4)](https://github.com/rayswoole "rayswoole (29 commits)")[![yunwuxin](https://avatars.githubusercontent.com/u/2168125?v=4)](https://github.com/yunwuxin "yunwuxin (16 commits)")[![big-dream](https://avatars.githubusercontent.com/u/9215157?v=4)](https://github.com/big-dream "big-dream (5 commits)")[![4352570](https://avatars.githubusercontent.com/u/51403503?v=4)](https://github.com/4352570 "4352570 (3 commits)")[![NHZEX](https://avatars.githubusercontent.com/u/14545600?v=4)](https://github.com/NHZEX "NHZEX (3 commits)")[![9007967](https://avatars.githubusercontent.com/u/33853639?v=4)](https://github.com/9007967 "9007967 (2 commits)")[![evalor](https://avatars.githubusercontent.com/u/26944445?v=4)](https://github.com/evalor "evalor (2 commits)")[![Tinywan](https://avatars.githubusercontent.com/u/14959876?v=4)](https://github.com/Tinywan "Tinywan (2 commits)")[![klinson](https://avatars.githubusercontent.com/u/41332835?v=4)](https://github.com/klinson "klinson (1 commits)")[![Alex-Yuen](https://avatars.githubusercontent.com/u/5312648?v=4)](https://github.com/Alex-Yuen "Alex-Yuen (1 commits)")[![pppscn](https://avatars.githubusercontent.com/u/5105854?v=4)](https://github.com/pppscn "pppscn (1 commits)")[![season886](https://avatars.githubusercontent.com/u/18523125?v=4)](https://github.com/season886 "season886 (1 commits)")[![shaukei](https://avatars.githubusercontent.com/u/1581783?v=4)](https://github.com/shaukei "shaukei (1 commits)")[![sy-records](https://avatars.githubusercontent.com/u/33931153?v=4)](https://github.com/sy-records "sy-records (1 commits)")[![tyson239](https://avatars.githubusercontent.com/u/5617150?v=4)](https://github.com/tyson239 "tyson239 (1 commits)")[![willove](https://avatars.githubusercontent.com/u/5616317?v=4)](https://github.com/willove "willove (1 commits)")[![hejiaqiang1980](https://avatars.githubusercontent.com/u/24983473?v=4)](https://github.com/hejiaqiang1980 "hejiaqiang1980 (1 commits)")[![hbh112233abc](https://avatars.githubusercontent.com/u/7788164?v=4)](https://github.com/hbh112233abc "hbh112233abc (1 commits)")[![iakihsoug](https://avatars.githubusercontent.com/u/5564630?v=4)](https://github.com/iakihsoug "iakihsoug (1 commits)")

---

Tags

databaseormswoolecoroutine

### Embed Badge

![Health badge](/badges/rayswoole-think-orm/health.svg)

```
[![Health](https://phpackages.com/badges/rayswoole-think-orm/health.svg)](https://phpackages.com/packages/rayswoole-think-orm)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[directorytree/ldaprecord

A fully-featured LDAP ORM.

5793.4M17](/packages/directorytree-ldaprecord)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[topthink/think-orm

the PHP Database&amp;ORM Framework

4372.1M242](/packages/topthink-think-orm)[cycle/database

DBAL, schema introspection, migration and pagination

71777.8k53](/packages/cycle-database)[hyperf/hyperf

A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.

6.9k3.3k2](/packages/hyperf-hyperf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
