PHPackages                             retentio/boomgo - 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. retentio/boomgo

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

retentio/boomgo
===============

Lightweight and straightforward PHP ODM for MongoDB

1.0.0-beta(14y ago)22603[3 issues](https://github.com/Retentio/Boomgo/issues)MITPHPPHP &gt;=5.3.2

Since Jan 1Pushed 12y ago3 watchersCompare

[ Source](https://github.com/Retentio/Boomgo)[ Packagist](https://packagist.org/packages/retentio/boomgo)[ Docs](https://github.com/Retentio/Boomgo)[ RSS](/packages/retentio-boomgo/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Boomgo, a micro PHP ODM for [MongoDB](http://www.mongodb.org/)
==============================================================

[](#boomgo-a-micro-php-odm-for-mongodb)

*Boomgo still a work in progress and is initially developped for [Retentio](http://retent.io)*

Boomgo is a **light** and **simple** Object Document Mapper on top of the [MongoDB php native driver](http://php.net/mongo).

[![Build Status](https://camo.githubusercontent.com/417089db64e5a0b1ed610964bfc7b75504d4f1bcc89be42cabdcf2b1ce49d1d7/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f526574656e74696f2f426f6f6d676f2e706e67)](http://travis-ci.org/Retentio/Boomgo)

Philosophy
----------

[](#philosophy)

Boomgo ODM focuses on the mapping process between PHP objects and MongoDB Documents, It doesn't abstract any feature provided by the native php driver. This way, Boomgo allows you to **keep the full control about your MongoDB interactions** (querying, map reduce, ...).

*In short, Boomgo offers a handy way to manipulate your MongoDB Documents with PHP Objects.*

Features
--------

[](#features)

Boomgo generate Mappers for your php object, which allow you to:

- Hydrate PHP Object from a MongoDB results set.
- Serialize PHP Object to mongo-storable array.
- Handle hydration process of embedded document / collection.

Requirements
------------

[](#requirements)

Boomgo was built with a lot of love (including best practices &amp; standards). It will only work for **PHP 5.3+ projects** which use a **structure matching** [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md). Furthermore, [composer](http://getcomposer.org/) usage is strongly encouraged.

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

[](#installation)

### Composer

[](#composer)

First, in your composer.json, add the requirement line for Boomgo.

```
{
    "require": {
        "retentio/boomgo": "dev-master"
    }
}
```

Then get composer and run the install command.

```
$ wget -nc -nv http://getcomposer.org/composer.phar
$ php composer.phar install
```

Usage
-----

[](#usage)

At the moment, Boomgo supports only annotation definition. Yet **it uses only a single tag**: by default "@Persistent" (you can change it). To persist some attributes of your model, Boomgo needs 3 things :

1. A dedicated &amp; unique namespace part for your persisted classes (default "Document").
2. The "@Persistent" tag in the property docblock.
3. Getter &amp; Setter for this property.

### Simple persistence

[](#simple-persistence)

```

```

Then, you can generate your mapper with the command (if you used composer):

```
$ vendor/bin/boomgo generate:mappers path/to/your/document/folder
```

Boomgo will generate (default: aside of your documents folder) a mapper class called `VendorName\Project\Mapper\MyPersistedClassMapper`. The mapper exposes 3 methods:

- `->serialize($yourObject)`
- `->unserialize($yourArray)`
- `->hydrate($yourObject, $yourArray)`

Then, the usage becomes really simple:

```
