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

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

analogue/orm
============

An intuitive Data Mapper ORM for PHP and Laravel

v6.2.0(6y ago)63447.4k51[8 issues](https://github.com/analogueorm/analogue/issues)3MITPHPPHP &gt;=7.2.0CI failing

Since Nov 28Pushed 6y ago28 watchersCompare

[ Source](https://github.com/analogueorm/analogue)[ Packagist](https://packagist.org/packages/analogue/orm)[ Docs](http://github.com/analogueorm/analogue)[ RSS](/packages/analogue-orm/feed)WikiDiscussions 5.6 Synced 2d ago

READMEChangelog (10)Dependencies (16)Versions (100)Used By (3)

(this project is looking for a new maintainer)

Analogue ORM
============

[](#analogue-orm)

[![Latest Stable Version](https://camo.githubusercontent.com/d0cf56b1d7d5ca4f25cd82f7bae187c58385b0777779461bbb18d120d506c10f/68747470733a2f2f706f7365722e707567782e6f72672f616e616c6f6775652f6f726d2f762f737461626c65)](https://packagist.org/packages/analogue/orm)[![Latest Unstable Version](https://camo.githubusercontent.com/a02c807e945a3b89e9c9eb9bfe277832debba1ad91242c1ddc36c4aa8ca86694/68747470733a2f2f706f7365722e707567782e6f72672f616e616c6f6775652f6f726d2f762f756e737461626c65)](https://packagist.org/packages/analogue/orm)[![License](https://camo.githubusercontent.com/ed970d19669424330a165199ab704f7b07b51825d8beea66a6f1cb478a3caa80/68747470733a2f2f706f7365722e707567782e6f72672f616e616c6f6775652f6f726d2f6c6963656e7365)](https://packagist.org/packages/analogue/orm)[![Build Status](https://camo.githubusercontent.com/75764a0d0a2ba701c6d2d0fcaa3fecefb0608fbce3bcadf2aabbd5b89d62ff82/68747470733a2f2f7472617669732d63692e6f72672f616e616c6f6775656f726d2f616e616c6f6775652e7376673f6272616e63683d352e36)](https://travis-ci.org/analogueorm/analogue.svg?branch=5.6)[![StyleCI](https://camo.githubusercontent.com/9dbff1efe4bf40f90aa09af4bcec1e9ea8e1e84344c33c1826b542ca684ec0cc/68747470733a2f2f7374796c6563692e696f2f7265706f732f32373236353336392f736869656c643f6272616e63683d352e36)](https://styleci.io/repos/27265369)

**Analogue** is a flexible, easy-to-use **ORM** for **PHP**. It is a transposition of the **Eloquent** ORM that ships with **Laravel** framework using a **Data Mapper** pattern instead of the original Active Record approach. it overcomes some of Eloquent's architectural limitations by using a strict separation of concerns; for example, you can use **Value Objects** or **Single-table-inheritance**, which are hard/impossible to implement correctly using the native ORM.

As a **Laravel package**, it integrates flawlessly inside the framework, and provides a more powerfull peristance layer, allowing to build enterprise-grade applications while retaining a simple and enjoyable development experience.

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

[](#installation)

```
composer require analogue/orm
```

See [Configuration](https://github.com/analogueorm/analogue/wiki/Installation) for more information.

Concept
-------

[](#concept)

The concept is simple; your model layer is defined using 2 classes : one **Entity**, which can be any PHP class or extends the base *Analogue\\ORM\\Entity* class which provides magic getters and setters, and one **EntityMap** which defines relationships, castings, table name, database column names.

Take this simple domain model :

```
use Analogue\ORM\Entity;
use Illuminate\Support\Collection;

class Blog extends Entity
{
    public function __construct()
    {
        $this->posts = new Collection;
    }

    public function addPost(Post $post)
    {
        $this->posts->push($post);
    }
}

class Post extends Entity
{

}
```

We can instruct **Analogue** how these objects are related using these classes :

```
use Analogue\ORM\EntityMap;

class BlogMap extends EntityMap
{
    public function posts(Blog $blog)
    {
        return $this->hasMany($blog, Post::class);
    }
}

class PostMap extends EntityMap
{
    public function blog(Post $post)
    {
        return $this->belongsTo($post, Blog::class);
    }
}
```

Now we can create related instance of or object and persist them to the database :

```
$blog = new Blog;
$blog->title = "My first blog";

$post = new Post;
$post->title->"My first post";

$blog->addPost($post);

// Only the blog instance need to explicitely stored; Analogue takes care of synchronizing
// related objects behinds the scene.

mapper(Blog::class)->store($blog);
```

Once our objects are persisted into the database, we can query them using the fluent query builder :

```
$blog = mapper(Blog::class)->first();

echo $blog->posts->first()->title; // 'My first post'
```

Documentation
-------------

[](#documentation)

Check the [Documentation](https://github.com/analogueorm/analogue/wiki) for more details.

Features
--------

[](#features)

- Framework agnostic
- Lazy loading
- Eager Loading
- Timestamps
- Soft Deletes
- Value Objects
- Polymorphic Relationships
- Dynamic Relationships
- Single table inheritance
- Cast entities to Array / Json
- Flexible event system
- Native multiple database connections support
- Extendable via custom database drivers / plugins

Changelog
---------

[](#changelog)

#### Version 5.6

[](#version-56)

- Laravel 5.6 support
- Bring back ability to map DB columns that name are not equals to the name of the attribute.
- Add ability to map DB snake case columns to camel case properties on entities.

#### Version 5.5

[](#version-55)

- Laravel 5.5 support
- Pushed miminum requirements to PHP7
- Complete support of Plain PHP objects via reflection based hydration/dehydration
- Improved Lazy-loading proxies.
- New, more flexible Value Object implementation, that can now be defined as `embedsOne()`, `embedsMany()` relationships
- Embedded value object can now be stored as a mysql JSON field
- Analogue entities can now be instantiated using laravel's `IoC Container` or any PSR-11 compatible container.
- Added [MongoDB](https://github.com/analogueorm/mongodb) driver.
- Package auto discovery (L5.5)

#### Version 5.4

[](#version-54)

- Illuminate 5.4 Compatibility.
- Add Ability to map DB columns that name are not equals to the name of the attribute.

#### Version 5.3

[](#version-53)

- Illuminate 5.3 Compatibility.
- Now fully support Single Table Inheritance.

#### Version 5.1

[](#version-51)

- Illuminate 5.1 + 5.2 Compatibility.

#### Version 5.0

[](#version-50)

- Analogue version now mirrors illuminate version.

#### Version 2.1.3

[](#version-213)

- Mutator feature in base Entity class.
- Ability to add entities to a proxy collection without lazyloading it.

### Version 2.1

[](#version-21)

- Package is now framework agnostic.
- Now support any plain object that implements Mappable interface.
- Introducing a MappableTrait for quick implementation.
- Queries can now be run directly on the mapper Object.
- Store/Delete methods now accept a array and collections as argument.
- EntityMap are now autodected when in the same namespace as the entity.
- Base Entity class Supports hidden attributes.
- Many workflow related improvements.

### Version 2.0

[](#version-20)

- Laravel 5 Support.

Documentation
-------------

[](#documentation-1)

Check the [wiki](https://github.com/analogueorm/analogue/wiki) for full documentation.

Licence
-------

[](#licence)

This package is licensed under the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity49

Moderate usage in the ecosystem

Community35

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 74.5% 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 ~21 days

Recently: every ~13 days

Total

93

Last Release

2272d ago

Major Versions

v1.0.4 → v2.02015-02-10

v2.1.10 → v5.02015-09-06

v5.6.15 → v6.0.02020-02-20

PHP version history (6 changes)v1.0.0PHP &gt;=5.4.0

v5.1PHP &gt;=5.5.0

v5.3.0PHP &gt;=5.6.4

v5.5.0PHP &gt;=7.0

v5.5.3PHP &gt;=7.0.0

v6.0.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f17700a18f8fa81ea5bef95c082b75fd42afe88d47c4cedc64f23771fece27f6?d=identicon)[RemiCollin](/maintainers/RemiCollin)

---

Top Contributors

[![RemiCollin](https://avatars.githubusercontent.com/u/9589616?v=4)](https://github.com/RemiCollin "RemiCollin (536 commits)")[![quetzyg](https://avatars.githubusercontent.com/u/1413966?v=4)](https://github.com/quetzyg "quetzyg (84 commits)")[![smallhadroncollider](https://avatars.githubusercontent.com/u/477286?v=4)](https://github.com/smallhadroncollider "smallhadroncollider (15 commits)")[![adrorocker](https://avatars.githubusercontent.com/u/1872940?v=4)](https://github.com/adrorocker "adrorocker (14 commits)")[![Evertt](https://avatars.githubusercontent.com/u/1267282?v=4)](https://github.com/Evertt "Evertt (12 commits)")[![tabennett](https://avatars.githubusercontent.com/u/2191397?v=4)](https://github.com/tabennett "tabennett (11 commits)")[![maxmirazh33](https://avatars.githubusercontent.com/u/2692282?v=4)](https://github.com/maxmirazh33 "maxmirazh33 (10 commits)")[![rickycheers](https://avatars.githubusercontent.com/u/480247?v=4)](https://github.com/rickycheers "rickycheers (7 commits)")[![cappuc](https://avatars.githubusercontent.com/u/4271608?v=4)](https://github.com/cappuc "cappuc (6 commits)")[![SerafimArts](https://avatars.githubusercontent.com/u/2461257?v=4)](https://github.com/SerafimArts "SerafimArts (5 commits)")[![hexus](https://avatars.githubusercontent.com/u/2626789?v=4)](https://github.com/hexus "hexus (4 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (4 commits)")[![clarodeus](https://avatars.githubusercontent.com/u/58027792?v=4)](https://github.com/clarodeus "clarodeus (2 commits)")[![shin1x1](https://avatars.githubusercontent.com/u/88324?v=4)](https://github.com/shin1x1 "shin1x1 (1 commits)")[![gdsmith](https://avatars.githubusercontent.com/u/908695?v=4)](https://github.com/gdsmith "gdsmith (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![graemetait](https://avatars.githubusercontent.com/u/64014?v=4)](https://github.com/graemetait "graemetait (1 commits)")[![kalvisbuls](https://avatars.githubusercontent.com/u/6388898?v=4)](https://github.com/kalvisbuls "kalvisbuls (1 commits)")[![kieranajp](https://avatars.githubusercontent.com/u/681426?v=4)](https://github.com/kieranajp "kieranajp (1 commits)")[![lex111](https://avatars.githubusercontent.com/u/4408379?v=4)](https://github.com/lex111 "lex111 (1 commits)")

---

Tags

data-mapperdatabaselaravelormphplaravelormentitymapperrepositorydatamapper

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)

PHPackages © 2026

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