PHPackages                             yangweijie/es-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. yangweijie/es-think-orm

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

yangweijie/es-think-orm
=======================

Think ORM adapter for EasySwoole - Provides connection pooling, coroutine context, and state isolation

v1.0.2(4mo ago)01Apache-2.0PHPPHP &gt;=7.4

Since Feb 24Pushed 4mo agoCompare

[ Source](https://github.com/yangweijie/es-think-orm)[ Packagist](https://packagist.org/packages/yangweijie/es-think-orm)[ RSS](/packages/yangweijie-es-think-orm/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

EasyOrm
=======

[](#easyorm)

Think ORM adapter for EasySwoole - Provides connection pooling, coroutine context, and state isolation.

Installation
------------

[](#installation)

```
composer require easyswoole/easy-orm
```

Features
--------

[](#features)

- **Connection Pooling**: Automatic management of database connections
- **Coroutine Context**: Safe database operations in Swoole coroutines
- **State Isolation**: Each request has independent database state
- **Multi-Database Support**: Multiple database connections with separate pools
- **Query Caching**: Built-in support for file and Redis caching
- **Transaction Management**: Coroutine-safe transaction support
- **Hot Reload**: Development mode hot reload support
- **Pool Monitoring**: Connection pool status monitoring

Quick Start
-----------

[](#quick-start)

### Configuration

[](#configuration)

```
// config/database.php
return [
    'default' => 'mysql',
    'connections' => [
        'mysql' => [
            'type' => 'mysql',
            'hostname' => '127.0.0.1',
            'database' => 'test',
            'username' => 'root',
            'password' => '',
            'hostport' => '3306',
            'charset' => 'utf8mb4',
            'debug' => true,
            'pool' => [
                'min_active' => 2,
                'max_active' => 10,
                'max_wait_time' => 5,
                'max_idle_time' => 60,
            ],
            'cache' => [
                'class' => 'EasyOrm\FileCacheHandler',
                'params' => [
                    'cache_dir' => EASYSWOOLE_ROOT . '/Temp/cache',
                ],
            ],
        ],
    ],
];
```

### Redis Cache Configuration

[](#redis-cache-configuration)

```
// config/database.php
return [
    'default' => 'mysql',
    'connections' => [
        'mysql' => [
            // ... database config ...
            'cache' => [
                'class' => 'EasyOrm\RedisCacheHandler',
                'params' => [
                    'host' => '127.0.0.1',
                    'port' => 6379,
                    'auth' => '',           // Redis password (optional)
                    'db_index' => 0,        // Redis database index
                    'timeout' => 3.0,       // Connection timeout
                ],
            ],
        ],
    ],
];
```

### Custom Cache Handler

[](#custom-cache-handler)

You can also create your own cache handler:

```
use EasyOrm\EasyDb;

// Create custom cache handler
class MyCacheHandler
{
    public function get($key)
    {
        // Return cached value or null
    }

    public function set($key, $value, $ttl = null)
    {
        // Store value, return bool
    }

    public function rm($key)
    {
        // Remove cached value, return bool
    }
}

// Set cache handler manually
EasyDb::setCacheHandler(new MyCacheHandler());
```

### Initialize in EasySwooleEvent

[](#initialize-in-easyswooleevent)

```
use EasyOrm\EasyDb;

public static function initialize()
{
    $config = require EASYSWOOLE_ROOT . '/config/database.php';
    EasyDb::init($config);
}
```

### Usage

[](#usage)

```
use EasyOrm\EasyDb;

// Basic query
$users = EasyDb::name('user')->where('status', 1)->select();

// With cache
$users = EasyDb::name('user')->cache(true, 60)->where('status', 1)->select();

// Transaction
EasyDb::transaction(function() {
    EasyDb::name('user')->insert(['name' => 'test']);
    EasyDb::name('order')->insert(['user_id' => 1]);
});
```

Documentation
-------------

[](#documentation)

See [API.md](/docs/API.md) for detailed API documentation.

License
-------

[](#license)

Apache-2.0

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance76

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

3

Last Release

128d ago

### Community

Maintainers

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

---

Top Contributors

[![yangweijie](https://avatars.githubusercontent.com/u/1614114?v=4)](https://github.com/yangweijie "yangweijie (5 commits)")

---

Tags

databaseormswoolecoroutineeasyswoolethink-orm

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony1/doctrine1

PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2

40685.2k](/packages/friendsofsymfony1-doctrine1)[simple-swoole/db

A db component for Simps.

216.8k3](/packages/simple-swoole-db)[icanboogie/activerecord

ActiveRecord Object-relational mapping

135.1k5](/packages/icanboogie-activerecord)

PHPackages © 2026

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