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

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

borschphp/orm
=============

An Object Relational Model implementation.

0.3(5y ago)026MITPHPPHP ^7.2

Since Jul 2Pushed 5y agoCompare

[ Source](https://github.com/borschphp/borsch-orm)[ Packagist](https://packagist.org/packages/borschphp/orm)[ RSS](/packages/borschphp-orm/feed)WikiDiscussions master Synced 5d ago

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

Borsch ORM
==========

[](#borsch-orm)

A framework agnostic Object Relational Model implementation, based on [Laminas-Db](https://docs.laminas.dev/laminas-db/), for Borsch Framework.

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

[](#installation)

Via [composer](https://getcomposer.org/) :

`composer require borschphp/orm`

Integration in Borsch Framework
-------------------------------

[](#integration-in-borsch-framework)

Create a new file `config/database.php` file then add this content inside :

```
use Borsch\Container\Container;
use Borsch\Db\Db;
use Laminas\Db\Adapter\AdapterInterface;

/**
 * Setup the database informations into the Borsch\Db\Db class.
 * It will be used later to deal with models.
 *
 * @param Container $container
 */
return function (Container $container): void {
    Db::addConnection($container->get(AdapterInterface::class), 'default');
};
```

Open the file `config/container.php` then add your AdapterInterface (=database connection) definition.
Example *(we've set some values in .env before)* :

```
/*
 * Database definitions
 * --------------------
 *
 * Borsch uses the laminas-db package, please check it out for more information :
 *     https://docs.laminas.dev/laminas-db/adapter/
 * You can update the database information in the .env file.
 */
$container->set(AdapterInterface::class, function () {
    return new Adapter([
        'driver'   => env('DB_DRIVER'),
        'database' => env('DB_NAME'),
        'username' => env('DB_USER'),
        'password' => env('DB_PWD'),
        'hostname' => env('DB_HOST'),
        'port' => env('DB_PORT'),
        'charset' => env('DB_CHARSET'),
        'driver_options' => [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
            PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_general_ci'
        ]
    ]);
})->cache(true);
```

Open the file `public/index.php`, then load your database settings, below the container instance :

```
/** @var ContainerInterface $container */
$container = (require_once __DIR__.'/../config/container.php');

(require_once __DIR__.'/../config/database.php')($container); // artist, $this->title);
    }

    public function setUpdatedAtProperty($value)
    {
        if (is_numeric($value)) {
            $value = date('Y-m-d H:i:s', $value);
        } elseif ($value instanceof DateTimeInterface) {
            $value = $value->format('Y-m-d H:i:s');
        }

        $this->updated_at = $value;
    }
}
```

You can create **accessors** and **mutators** for your class properties (*getCreatedAtProperty*, *setUpdatedAtProperty*).
It is also possible to create accessors for no properties (*getArtistTitleProperty*).

Your class $id, $created\_at and $updated are already set in `Borsch\ORM\Model`, you do not need to define them.

Active Records
--------------

[](#active-records)

You can easily create or update element in your database in an Active Record way :

```
$album = new Album();
$album->artist = 'Muse';
$album->title = 'The Resistance';
$album->save(); // Saved

$album = Album::where(['title' => 'The Resistance', 'artist' => 'Muse'])->first();
$album->title = 'Absolution';
$album->save(); // Updated

$album->delete(); // Deleted
```

Query Builder
-------------

[](#query-builder)

As said, the package is based on [Laminas-Db](https://docs.laminas.dev/laminas-db/), therefore you can use the fluent [SQL Abstraction](https://docs.laminas.dev/laminas-db/sql/) to fetch your data.

License
-------

[](#license)

The package is licensed under the MIT license. See [License File](https://github.com/borschphp/orm/blob/master/LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Total

3

Last Release

2110d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1a70117520fe10a630d61c750bbe6888d174e9903825e741470f818ee2c5d1?d=identicon)[debuss-a](/maintainers/debuss-a)

---

Top Contributors

[![debuss](https://avatars.githubusercontent.com/u/2537607?v=4)](https://github.com/debuss "debuss (3 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[doctrine/doctrine-laminas-hydrator

Doctrine hydrators for Laminas applications

362.8M19](/packages/doctrine-doctrine-laminas-hydrator)[laminas-api-tools/api-tools-doctrine

Laminas API Tools Doctrine module

10633.9k5](/packages/laminas-api-tools-api-tools-doctrine)

PHPackages © 2026

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