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 9mo agoCompare

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

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 4% of packages

Maintenance40

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

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

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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