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

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

bravo3/orm
==========

NoSQL ORM for databases such as Redis

0.5.13(10y ago)619.0k4[1 PRs](https://github.com/bravo3/orm/pulls)2MITPHPPHP &gt;=5.5.0

Since Jan 6Pushed 10y ago9 watchersCompare

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

READMEChangelog (10)Dependencies (10)Versions (68)Used By (2)

Document Object Relational Mapper
=================================

[](#document-object-relational-mapper)

Purpose
-------

[](#purpose)

The purpose of this library is to blend ORM and ODM fundamentals with NoSQL database platforms, allowing you to use NoSQL databases with pseudo-relationships through means of a traditional entity manager.

Table of Contents
-----------------

[](#table-of-contents)

- [Drivers](docs/Drivers.md)
- [Entity Mapping Definitions](docs/EntityDefinitions.md)
- [Events](docs/Events.md)
- [PubSub](docs/PubSub.md)
- [Important Notes](docs/ImportantNotes.md)
- [Index Types](docs/IndexTypes.md)
- [Key Schemes](docs/KeySchemes.md)
- [Project Structure](docs/ProjectStructure.md)
- [Queries](docs/Queries.md)
- [Race Conditions](docs/RaceConditions.md)
- [Serialisers](docs/Serialisers.md)
- [Mappers - Yaml](docs/Mappers/Yaml.md)

Further Examples
----------------

[](#further-examples)

- [Auto-updating Time Stamps](docs/Examples/ModifyTime.md)
- [Getters and Setters](docs/Examples/GettersSetters.md)
- [Lookup Indices](docs/Examples/Index.md)
- [Multi-Column IDs](docs/Examples/MultiColumnId.md)
- [Sorted Relationships](docs/Queries.md)

Advanced/Internals
------------------

[](#advancedinternals)

- [Refs](docs/Advanced/Refs.md)
- [Entity Locator](docs/Advanced/EntityLocator.md)

Example
-------

[](#example)

If you intend to use Redis, please include Predis in your `composer.json`:

```
"require": {
    "predis/predis": "~1.0"
}

```

Creating an entity manager for a Redis database with annotation mappings:

```
$em = new EntityManager(
    new RedisDriver(['host' => 'example.com']),
    new AnnotationMapper()
);

```

Persisting a simple relationship:

```
$address = new Address();
$address->setId(1)->setStreet("123 Example St");

$user = new User();
$user->setId(1)->setName("Harry")->setAddress($address);

$em->persist($user)->persist($address)->flush();

```

Retrieving a relationship with lazy-loading:

```
$user = $em->retrieve('User', 1);   // Only user entity retrieved
$address = $user->getAddress();     // DB call to get address made here

```

Example entity files:

*User.php*

```
