PHPackages                             vegas-cmf/odm - 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. vegas-cmf/odm

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

vegas-cmf/odm
=============

Vegas CMF ODM

v3.0.0(9y ago)135MITPHPPHP ^5.6 || ^7.0

Since Apr 27Pushed 9y ago4 watchersCompare

[ Source](https://github.com/vegas-cmf/odm)[ Packagist](https://packagist.org/packages/vegas-cmf/odm)[ RSS](/packages/vegas-cmf-odm/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (6)Versions (8)Used By (0)

Vegas CMF ODM
=============

[](#vegas-cmf-odm)

[![Travis Status](https://camo.githubusercontent.com/3ea4c75764f644186d5404401bc9212908d38c273dc05186590ad181e9379357/68747470733a2f2f7472617669732d63692e6f72672f76656761732d636d662f6f646d2e7376673f6272616e63683d666561747572652d70726f7879)](https://travis-ci.org/vegas-cmf/modmvc.svg?branch=feature-proxy)[![Coverage Status](https://camo.githubusercontent.com/8382fb0a3bdc726bcaf9d90c6ef159fb34986b6ec75e045e8ff9d54c516bfe9a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f76656761732d636d662f6f646d2f62616467652e7376673f6272616e63683d666561747572652d70726f7879)](https://coveralls.io/github/vegas-cmf/odm?branch=feature-proxy)

Compatible with: Phalcon &gt;= 2.0

Example usage
-------------

[](#example-usage)

*Collections definition*

```
namespace Fixtures\Collection;

use \Vegas\ODM\Collection;

class Category extends Collection
{
    /**
     * @var string
     */
    protected $name;

    /**
     * @var string
     */
    protected $desc;

    /**
     * @var \Fixtures\Collection\Category
     * @Mapper
     */
    protected $category;

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param mixed $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return mixed
     */
    public function getDesc()
    {
        return $this->desc;
    }

    /**
     * @param mixed $desc
     */
    public function setDesc($desc)
    {
        $this->desc = $desc;
    }

    /**
     * @return Category
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * @param Category $category
     */
    public function setCategory($category)
    {
        $this->category = $category;
    }

    public function getSource()
    {
        return 'vegas_app_categories';
    }
}

//---------------------
namespace Fixtures\Collection;

use \Vegas\ODM\Collection;

class Product extends Collection
{
    /**
     * @var string
     */
    protected $name;

    /**
     * @var \Fixtures\Collection\Category
     * @Mapper
     */
    protected $category;

    /**
     * @var int
     * @Mapper
     */
    protected $price;

    /**
     * @var \MongoDate
     * @Mapper \Vegas\ODM\Mapping\Mapper\MongoDate
     */
    protected $createdAt;

    /**
     * @var boolean
     * @Mapper
     */
    protected $isActive;

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return Category
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * @param Category $category
     */
    public function setCategory(Category $category)
    {
        $this->category = $category;
    }

    /**
     * @return int
     */
    public function getPrice()
    {
        return $this->price;
    }

    /**
     * @param $price
     */
    public function setPrice($price)
    {
        $this->price = $price;
    }

    /**
     * @return \MongoDate
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * @param $createdAt
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;
    }

    /**
     * @return boolean
     */
    public function isActive()
    {
        return $this->isActive;
    }

    /**
     * @param boolean $isActive
     */
    public function setIsActive($isActive)
    {
        $this->isActive = $isActive;
    }

    public function getSource()
    {
        return 'vegas_app_products';
    }
}
```

*Working with documents*

```
$parentCategory = new Category();
$parentCategory->setName('Category 0');
$parentCategory->setDesc('Category 0 desc');
$parentCategory->save();

$category = new Category();
$category->setName('Category 1');
$category->setDesc('Category 1 desc');
$category->setCategory($parentCategory);
$category->save();

$product = new Product();
$product->setName('Product 1');
$product->setPrice(100);
$product->setIsActive(true);
$product->setCategory($category);
$product->setCreatedAt(time());

$product->save();

// by default Eager loading is enabled

$testProduct = Product::findFirst();
var_dump($testProduct->getCategory()->getName()); // Category 1
var_dump($testProduct->getCreatedAt()); // \MongoDate
var_dump($testProduct->getPrice()); // 100
var_dump($testProduct->getCategory()->getCategory()->getName()); // Category 0

// with disabled eager loading - efficient for big dataset

$testProduct = Product::findFirst();
var_dump($testProduct->getCategory()); // MongoId
var_dump($testProduct->getCreatedAt()); // int
var_dump($testProduct->isActive()); // true
var_dump($testProduct->getPrice()); // 100
var_dump($testProduct->getCategory()->getCategory()->getName()); // error!
```

Mapping cache
-------------

[](#mapping-cache)

```
$config = new \Phalcon\Config([
    'mapping' => [
        'cache' => [
            'frontend' => [
                'driverClass' => 'Phalcon\Cache\Frontend\Output',
                'parameters' => [
                    'lifetime' => 3600
                ]
            ],
            'backend' => [
                'driverClass' => '\Phalcon\Cache\Backend\Mongo',
                'parameters' => [
                    'server' => 'localhost',
                    'db' => 'vegas_test',
                    'collection' => 'cache'
                ]
            ],
        ]
    ]
]);

$di->set('odmMappingCache', function() use ($di, $config) {
    $frontCacheClass = $config->mapping->cache->frontend->driverClass;
    $frontCache = new $frontCacheClass(
        $config->mapping->cache->frontend->parameters->toArray()
    );
    $backCacheClass = $config->mapping->cache->backend->driverClass;
    $cache = new $backCacheClass(
        $frontCache,
        $config->mapping->cache->backend->parameters->toArray()
    );

    return $cache;
}, true);
```

Mapping
-------

[](#mapping)

Vegas ODM resolves referenced documents automatically. References must be defined in collection class by annotation. Consider the following code

```
class Test extends \Vegas\ODM\Collection {
    /**
     * @var \MongoId
     * @mapper \Vegas\ODM\Mapping\Mapper\MongoId
     */
    protected $_id;

    /**
     * @var int
     * @mapper
     */
    protected $int;

    /**
     * @var \MongoDate
     * @Mapper \Vegas\ODM\Mapping\Mapper\MongoDate
     */
    protected $date;
}
```

Annotation *@var* determines the variable type. Annotation *@mapper* (*@Mapper*) determines that property value will be mapped (casted) to value defined by *@var*. In *@mapper* annotation you can specify custom mapper class. (Note! Mapping class must implements interface *\\Vegas\\ODM\\Mapping\\MapperInterface*)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 70% 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 ~98 days

Total

5

Last Release

3321d ago

Major Versions

v2.0.2-beta → v3.0.x-dev2016-08-19

PHP version history (2 changes)v2.0.0-betaPHP &gt;=5.4

v3.0.x-devPHP ^5.6 || ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/46222392?v=4)[vegas](/maintainers/vegas)[@vegas](https://github.com/vegas)

---

Top Contributors

[![szytko](https://avatars.githubusercontent.com/u/300085?v=4)](https://github.com/szytko "szytko (28 commits)")[![maniolek](https://avatars.githubusercontent.com/u/3389670?v=4)](https://github.com/maniolek "maniolek (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vegas-cmf-odm/health.svg)

```
[![Health](https://phpackages.com/badges/vegas-cmf-odm/health.svg)](https://phpackages.com/packages/vegas-cmf-odm)
```

###  Alternatives

[analogue/orm

An intuitive Data Mapper ORM for PHP and Laravel

63447.3k3](/packages/analogue-orm)[bravo3/orm

NoSQL ORM for databases such as Redis

619.0k2](/packages/bravo3-orm)

PHPackages © 2026

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