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

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

topthink/think-orm
==================

the PHP Database&amp;ORM Framework

v4.0.51(5mo ago)4542.0M↑17.9%186[139 issues](https://github.com/top-think/think-orm/issues)[15 PRs](https://github.com/top-think/think-orm/pulls)20Apache-2.0PHPPHP &gt;=8.0.0CI passing

Since Oct 27Pushed 3mo ago21 watchersCompare

[ Source](https://github.com/top-think/think-orm)[ Packagist](https://packagist.org/packages/topthink/think-orm)[ RSS](/packages/topthink-think-orm/feed)WikiDiscussions 4.0 Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (184)Used By (20)

ThinkORM4.0
===========

[](#thinkorm40)

基于PHP8.0+ 和PDO实现的轻量级ORM，完全重构的Model层，支持实体模型和分层（[新特性盘点](https://doc.thinkphp.cn/@think-orm/v4_0/new-features.html)），并基本兼容3.0（参考[升级指导](https://doc.thinkphp.cn/@think-orm/v4_0/upgrade.html)）。

特性
--

[](#特性)

- 基于PDO和PHP强类型实现
- 原生查询支持
- 灵活的查询构造器和链式查询
- 自动参数绑定和预查询
- 聚合查询
- 强大的模型及关联定义
- 模型获取器和修改器
- 虚拟模型支持
- 实体模型和视图模型支持
- 支持ActiveRecord模式和仓储模式
- 模型事件和类型自动转换
- 数据自动写入和延迟写入
- 搜索器和查询范围
- 预载入关联查询和延迟关联查询
- 数据写入自动验证
- 多数据库和`MongoDb`支持
- 分布式及事务、断点重连
- `JSON`及枚举类支持
- `PSR-16`缓存及`PSR-3`日志规范

安装
--

[](#安装)

```
composer require topthink/think-orm

```

文档
--

[](#文档)

详细参考 [ThinkORM开发指南](https://doc.thinkphp.cn/@think-orm)

基于官方手册的数据训练和提供精准解答服务 [官方专家智能体](https://chat.topthink.com/chat/e7m6qe)

你可以使用官方提供的[ThinkChat](https://chat.topthink.com/)，让你在学习 ThinkPHP 的旅途中享受私人 AI 助理服务！

[![](https://camo.githubusercontent.com/6a86ae00932359642f7b4b40a41ddd84e4deae3d9c5dfcab9fdabb93d8018b37/68747470733a2f2f7777772e746f707468696e6b2e636f6d2f75706c6f6164732f617373697374616e742f32303233303633302f34643161336630616432393538623439626238313839623765663832346362302e706e67)](https://chat.topthink.com/)

ThinkPHP 生态服务由[顶想云](https://www.topthink.com)（TOPThink Cloud）提供，为生态提供专业的开发者服务和价值之选。

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance71

Regular maintenance activity

Popularity63

Solid adoption and visibility

Community53

Growing community involvement

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85.8% 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 ~16 days

Recently: every ~43 days

Total

183

Last Release

106d ago

Major Versions

v2.0.61 → v3.0.92023-04-20

v2.0.62 → v3.0.282024-10-10

v3.0.33 → v4.0-beta2024-12-24

v3.0.34 → v4.0.02025-01-23

3.0.x-dev → v4.0.512025-12-18

PHP version history (3 changes)0.1PHP &gt;=5.6.0

v2.0.0PHP &gt;=7.1.0

v3.0.0PHP &gt;=8.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7858077?v=4)[topthink](/maintainers/topthink)[@topthink](https://github.com/topthink)

![](https://www.gravatar.com/avatar/7422243107bba2d58c5682b69d1c405e66fa027df2f6202afc1bb0c55559a7b1?d=identicon)[yunwuxin](/maintainers/yunwuxin)

---

Top Contributors

[![liu21st](https://avatars.githubusercontent.com/u/1111670?v=4)](https://github.com/liu21st "liu21st (1115 commits)")[![NHZEX](https://avatars.githubusercontent.com/u/14545600?v=4)](https://github.com/NHZEX "NHZEX (41 commits)")[![yunwuxin](https://avatars.githubusercontent.com/u/2168125?v=4)](https://github.com/yunwuxin "yunwuxin (36 commits)")[![big-dream](https://avatars.githubusercontent.com/u/9215157?v=4)](https://github.com/big-dream "big-dream (23 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (11 commits)")[![YepYuYu](https://avatars.githubusercontent.com/u/84311710?v=4)](https://github.com/YepYuYu "YepYuYu (11 commits)")[![Hhh0121](https://avatars.githubusercontent.com/u/127706674?v=4)](https://github.com/Hhh0121 "Hhh0121 (8 commits)")[![hbh112233abc](https://avatars.githubusercontent.com/u/7788164?v=4)](https://github.com/hbh112233abc "hbh112233abc (6 commits)")[![ichynul](https://avatars.githubusercontent.com/u/10061650?v=4)](https://github.com/ichynul "ichynul (5 commits)")[![season886](https://avatars.githubusercontent.com/u/18523125?v=4)](https://github.com/season886 "season886 (5 commits)")[![wolf-leo](https://avatars.githubusercontent.com/u/37436228?v=4)](https://github.com/wolf-leo "wolf-leo (3 commits)")[![4352570](https://avatars.githubusercontent.com/u/51403503?v=4)](https://github.com/4352570 "4352570 (3 commits)")[![yuanzhihai](https://avatars.githubusercontent.com/u/15060466?v=4)](https://github.com/yuanzhihai "yuanzhihai (3 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (3 commits)")[![phpdog](https://avatars.githubusercontent.com/u/6801280?v=4)](https://github.com/phpdog "phpdog (3 commits)")[![zoujingli](https://avatars.githubusercontent.com/u/4349951?v=4)](https://github.com/zoujingli "zoujingli (2 commits)")[![9007967](https://avatars.githubusercontent.com/u/33853639?v=4)](https://github.com/9007967 "9007967 (2 commits)")[![augushong](https://avatars.githubusercontent.com/u/31880431?v=4)](https://github.com/augushong "augushong (2 commits)")[![evalor](https://avatars.githubusercontent.com/u/26944445?v=4)](https://github.com/evalor "evalor (2 commits)")[![gitlilimin](https://avatars.githubusercontent.com/u/32194203?v=4)](https://github.com/gitlilimin "gitlilimin (2 commits)")

---

Tags

databaseormdatabaseorm

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

203.7k](/packages/perplorm-perpl)

PHPackages © 2026

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