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

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

tivins/orm
==========

basic php orm

03PHP

Since Sep 12Pushed 8mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

ORM
===

[](#orm)

Install
-------

[](#install)

```
composer install tivins/orm
```

Configuration
-------------

[](#configuration)

ORM use [Tivins/Database](https://github.com/tivins/database).

```
use Tivins\ORM\DB;
use Tivins\Database\Database;
use Tivins\Database\Connectors\MySQLConnector;

# Define ORM/DB::$db with mysql connection.
DB::$db = new Database(new MySQLConnector('my_database', 'root', 'secret'));
```

basic example
-------------

[](#basic-example)

### 1 - Create a model

[](#1---create-a-model)

```
use Tivins\App\Models;
use \Tivins\ORM\Table;
use \Tivins\ORM\Column;

#[Table('books')]
class Book extends Model
{
    #[Column(primary: true)]
    protected int $id = 0;

    #[Column]
    protected string $title = '';

    #[Column]
    protected string $author = '';

    #[Column]
    protected int $year = 0;

    // add getters/setters,
    // and custom methods.
}
```

Usage:

```
# create
$book = (new Book())
    ->setTitle("Le Petit Prince")
    ->setAuthor("Antoine de Saint-Exupéry")
    ->setYear(1943)
    ->save();
$book->getId(); // ex: 123

# load and update
$book = Book::getInstance(123);
$book->setTitle("Changed title")->save();
$book->getId(); // 123

# load by
$book = (new Book())->loadBy(['name' => 'Changed title']);
$book->getId(); // 123
```

Collection
----------

[](#collection)

```
// Get an array of objects
$books = Book::getSelectQuery('b')->addFields('b')->execute()->fetchAll();
// convert to Book[] array.
$books = Book::mapCollection($books);
```

Please, refer to [Database documentation](https://github.com/tivins/database) to learn more about `SelectQuery`.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance43

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/13aae62b30274178dfd8d18ce4b6bee1a7d7bcbc9db17c2d22b2be5c7b51edc4?d=identicon)[Tivins](/maintainers/Tivins)

---

Top Contributors

[![tivins](https://avatars.githubusercontent.com/u/479448?v=4)](https://github.com/tivins "tivins (7 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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