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

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

leven-framework/orm
===================

1.4.0(3y ago)051PHP

Since Apr 28Pushed 3y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

Leven ORM
=========

[](#leven-orm)

Features
--------

[](#features)

- 💾 easily map pure PHP objects to a database
- ⛓ intuitive relationship mapping
- 🔧 configure entities with PHP8 attributes
- 🧪 easily testable with a mock database - uses [Leven Database Adapter](https://github.com/leven-framework/dba-common)
- 🔤 automatic table and column name mapping
- 🐌 automatic eager loading and caching
- 🔝 support for auto-incrementing primary props
- 📁 all props are stored JSON-encoded in a single column

Example
-------

[](#example)

```
require 'vendor/autoload.php';

$repo = new \Leven\ORM\Repository(
    new \Leven\DBA\MySQL\MySQLAdapter(
        database: 'example',
        user: 'username',
        password: 'password',
    )
);

(new \Leven\ORM\RepositoryConfigurator($repo))
    ->scanEntityClasses();

class Author extends \Leven\ORM\Entity {
    #[\Leven\ORM\Attribute\PropConfig(primary: true)]
    public int $id;

    public function __construct(
        public string $name;
    ){}
}

class Book extends \Leven\ORM\Entity {
    #[\Leven\ORM\Attribute\PropConfig(primary: true)]
    public int $id;

    public function __construct(
        // this defines that each Book must belong to an Author
        public Author $author;

        // we can provide rules for the Book's title
        #[\Leven\ORM\Attribute\ValidationConfig(notEmpty: true, maxLength: 256)]
        public string $title;

        // store this prop in a separate column, so we can search for entities by it
        #[\Leven\ORM\Attribute\PropConfig(index: true)]
        public string $isbn;

        // when storing or reading to the db, we'll use a converter to convert this prop to/from a scalar value
        #[\Leven\ORM\Attribute\PropConfig(converter: \Leven\ORM\Converter\DateTimeStringConverter::class)]
        public DateTime $releaseDate;
    ){}
}

$john = new Author('John Doe');
$example = new Book($author, 'Example Book', '123456789', new DateTime('2021-01-01'));
$repo->store($john, $example);

// later...

$author = $repo->get(Author::class, 1); // get author with id 1
$books = $repo->findChildrenOf($author, Book::class)->get();

$book = $repo->find(Book::class)->where('isbn', '123456789')->getFirst();
$book->title = 'New Title';
$repo->update($book);
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Total

5

Last Release

1406d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82e25ee9c2189d89148b77cb15477330861242577535ff77a73773aba317e369?d=identicon)[leongrdic](/maintainers/leongrdic)

---

Top Contributors

[![leongrdic](https://avatars.githubusercontent.com/u/6260068?v=4)](https://github.com/leongrdic "leongrdic (37 commits)")

---

Tags

abstractiondatabasemappermappingobject-relational-mapperormphpphp-attributesphp8relations

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/leven-framework-orm/health.svg)](https://phpackages.com/packages/leven-framework-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)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

PHPackages © 2026

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