PHPackages                             royalcms/database - 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. royalcms/database

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

royalcms/database
=================

The Royalcms Database package.

v7.1.2(6y ago)0121MITPHPPHP ^7.2.5

Since Feb 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/royalcms/royalcms-database)[ Packagist](https://packagist.org/packages/royalcms/database)[ Docs](http://royalcms.cn)[ RSS](/packages/royalcms-database/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (6)Used By (1)

Royalcms Database
-----------------

[](#royalcms-database)

The Royalcms Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder. It currently supports MySQL, Postgres, SQL Server, and SQLite. It also serves as the database layer of the Royalcms PHP framework.

### Usage Instructions

[](#usage-instructions)

First, create a new "Capsule" manager instance. Capsule aims to make configuring the library for usage outside of the Royalcms framework as easy as possible.

```
use Royalcms\Component\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'database',
    'username'  => 'root',
    'password'  => 'password',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
]);

// Set the event dispatcher used by Eloquent models... (optional)
use Royalcms\Component\Events\Dispatcher;
use Royalcms\Component\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));

// Make this Capsule instance available globally via static methods... (optional)
$capsule->setAsGlobal();

// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
$capsule->bootEloquent();
```

> `composer require "royalcms/events"` required when you need to use observers with Eloquent.

Once the Capsule instance has been registered. You may use it like so:

**Using The Query Builder**

```
$users = Capsule::table('users')->where('votes', '>', 100)->get();
```

Other core methods may be accessed directly from the Capsule in the same manner as from the DB facade:

```
$results = Capsule::select('select * from users where id = ?', array(1));
```

**Using The Schema Builder**

```
Capsule::schema()->create('users', function($table)
{
    $table->increments('id');
    $table->string('email')->unique();
    $table->timestamps();
});
```

**Using The Eloquent ORM**

```
class User extends Royalcms\Component\Database\Eloquent\Model {}

$users = User::where('votes', '>', 1)->get();
```

For further documentation on using the various database facilities this library provides, consult the [Royalcms framework documentation](http://royalcms.cn/docs).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~104 days

Total

5

Last Release

2214d ago

Major Versions

v5.0.1 → 7.x-dev2020-04-22

PHP version history (2 changes)v5.0.0PHP &gt;=5.5.9

7.x-devPHP ^7.2.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1106638?v=4)[Hao.Dongfang](/maintainers/royalwang)[@royalwang](https://github.com/royalwang)

---

Top Contributors

[![royalwang](https://avatars.githubusercontent.com/u/1106638?v=4)](https://github.com/royalwang "royalwang (1 commits)")

---

Tags

databaseormsqlroyalcms

### Embed Badge

![Health badge](/badges/royalcms-database/health.svg)

```
[![Health](https://phpackages.com/badges/royalcms-database/health.svg)](https://phpackages.com/packages/royalcms-database)
```

###  Alternatives

[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[dbout/wp-orm

WordPress ORM with Eloquent.

1279.6k1](/packages/dbout-wp-orm)[agungsugiarto/codeigniter4-eloquent

The Illuminate Database package for CodeIgniter 4

264.5k](/packages/agungsugiarto-codeigniter4-eloquent)[bigsinoos/j-eloquent

Convert eloquent date attributes to jalali (Persian) dates on the fly. (supports model propery access, toJson, toString and toArray).

224.7k](/packages/bigsinoos-j-eloquent)

PHPackages © 2026

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