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

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

vakata/orm
==========

An ORM implementation

7.3.0(8y ago)6863MITPHPPHP &gt;=7.0.0

Since Nov 29Pushed 8y ago2 watchersCompare

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

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

orm
===

[](#orm)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ac5d5a9a9d6c38c1d1e952c07bcb37fa47bede44f252f2ca75211103cd960686/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f76616b6174612f6f726d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vakata/orm)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/afcf7a46d8313262063251dd1653eea5c0055588ff268f4cde9b14d9425f5904/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f76616b6174612f6f726d2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/vakata/orm)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/15805b0533ce10f7241c0121b3741d2021051e9a72afa41f20c9c6c6d52556aa/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f76616b6174612f6f726d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vakata/orm)[![Code Coverage](https://camo.githubusercontent.com/dc8777ef257b2330ed063c5b601a23182c11beb000d2f8c49ebd2aab6eae053e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f76616b6174612f6f726d2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vakata/orm)

A orm abstraction with support for various drivers.

Install
-------

[](#install)

Via Composer

```
$ composer require vakata/orm
```

Usage
-----

[](#usage)

```
// first you need a database instance
$db = new \vakata\database\DB('mysql://root@127.0.0.1/test');

// then you can create the manager object
$manager = new \vakata\orm\Manager($db);

// assuming there is a book table with a name column
foreach ($manager->book() as $book) {
    echo $book->name . "\n";
}
// you could of course filter and order
foreach ($manager->book()->filter('year', 2016)->sort('name') as $book) {
    // iterate over the books from 2016
}

// if using mySQL foreign keys are automatically detected
// for example if there is an author table and the book table references it
foreach ($manager->book() as $book) {
    echo $book->author->name . "\n";
}

// you can solve the n+1 queries problem like this
foreach ($manager->fromQuery($db->book()->with('author')) as $book) {
    echo $book->author->name . "\n";
}

// provided there is a linking table book_tag and a tag table and each book has many tags you can do this
foreach ($manager->book()->with('author') as $book) {
    echo $book->tag[0]->name . "\n"; // the name of the first tag which the current book has
}

// which means you can do something like this
echo $manager->book()[0]->author->book[0]->tag[0]->book[0]->author->name;

// as for removing objects
$authors = $manager->author();
$author = $authors[0];
$authors->remove($author);

// you can also create new objects
$book = new \StdClass();
$book->name = 'Test';
$manager->books()->add($book);

// you can also use your own classes
// just make sure you provide getters and setters for all table columns and relations
class Author
{
    protected $data = [];
    public function __get($key) { return $this->data[$key] ?? null; }
    public function __set($key, $value) { $this->data[$key] = $value; }
}
$manager->registerGenericMapperWithClassName('author', Author::class); // you can also add custom mappers (check the docs)
$author = $manager->author()[0]; // this is an Author instance

// as for changing objects
// one way is to do it manually
$authors = $manager->author();
$author = $authors[0];
$author->name = "Test";
$manager->getMapper('author')->update($author);

// or use the unit of work manager and have all changes automatically saved
$manager = new \vakata\orm\UnitOfWorkManager($db, new \vakata\orm\UnitOfWork($db));
$book = new Book();
$book->name = "Book name";
$book->author = $manager->author()->find(1);
$tag = new Tag('tag');
$book->tags = $tag;
$book->author->name = "Changed name";
$manager->books()->add($book);
$manager->tags()->add($tag);
// all you need to do is call this line
$manager->save();
```

Read more in the [API docs](docs/README.md)

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [vakata](https://github.com/vakata)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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

Recently: every ~40 days

Total

53

Last Release

2958d ago

Major Versions

2.2.2 → 3.0.02016-10-21

3.1.1 → 4.0.02016-11-24

4.0.8 → 5.0.02017-01-26

5.1.3 → 6.0.02017-04-25

6.2.5 → 7.0.02017-05-19

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

7.1.2PHP &gt;=7.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/146052?v=4)[Ivan Bozhanov](/maintainers/vakata)[@vakata](https://github.com/vakata)

---

Top Contributors

[![vakata](https://avatars.githubusercontent.com/u/146052?v=4)](https://github.com/vakata "vakata (86 commits)")

---

Tags

ormvakata

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k295.3M7.2k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k249.9M3.9k](/packages/doctrine-doctrine-bundle)[doctrine/persistence

The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

4.0k298.2M965](/packages/doctrine-persistence)[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k122.6M412](/packages/gedmo-doctrine-extensions)[illuminate/database

The Illuminate Database package.

2.8k54.1M11.2k](/packages/illuminate-database)[beberlei/doctrineextensions

A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.

2.1k78.1M170](/packages/beberlei-doctrineextensions)

PHPackages © 2026

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