All Projects → analogueorm → Analogue

analogueorm / Analogue

Licence: mit
Analogue ORM : Data Mapper ORM for Laravel/PHP

Projects that are alternatives of or similar to Analogue

Laravel Optimistic Locking
Adds optimistic locking feature to eloquent models.
Stars: ✭ 71 (-88.51%)
Mutual labels:  orm, database, laravel
Gorose
GoRose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides six major database drivers: mysql,sqlite3,postgres,oracle,mssql, Clickhouse.
Stars: ✭ 947 (+53.24%)
Mutual labels:  orm, database, laravel
Laravel Backup
A package to backup your Laravel app
Stars: ✭ 4,752 (+668.93%)
Mutual labels:  database, laravel
Wp Eloquent
Eloquent ORM for WordPress
Stars: ✭ 478 (-22.65%)
Mutual labels:  orm, database
Pg
Golang ORM with focus on PostgreSQL features and performance
Stars: ✭ 4,918 (+695.79%)
Mutual labels:  orm, database
Android Orma
An ORM for Android with type-safety and painless smart migrations
Stars: ✭ 442 (-28.48%)
Mutual labels:  orm, database
Nohm
node.js object relations mapper (orm) for redis
Stars: ✭ 462 (-25.24%)
Mutual labels:  orm, database
Ormlite Core
Core ORMLite functionality that provides a lite Java ORM in conjunction with ormlite-jdbc or ormlite-android
Stars: ✭ 488 (-21.04%)
Mutual labels:  orm, database
Closuretable
Adjacency List’ed Closure Table database design pattern implementation for the Laravel framework.
Stars: ✭ 391 (-36.73%)
Mutual labels:  database, laravel
Hibernate Orm
Hibernate's core Object/Relational Mapping functionality
Stars: ✭ 4,806 (+677.67%)
Mutual labels:  orm, database
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (-19.42%)
Mutual labels:  orm, database
Qb
The database toolkit for go
Stars: ✭ 524 (-15.21%)
Mutual labels:  orm, database
Performance
⏱ PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
Stars: ✭ 429 (-30.58%)
Mutual labels:  database, laravel
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (-31.39%)
Mutual labels:  database, laravel
Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+659.71%)
Mutual labels:  orm, database
Gnorm
A database-first code generator for any language
Stars: ✭ 415 (-32.85%)
Mutual labels:  orm, database
Maghead
The fastest pure PHP database framework with a powerful static code generator, supports horizontal scale up, designed for PHP7
Stars: ✭ 483 (-21.84%)
Mutual labels:  orm, database
Go Sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
Stars: ✭ 539 (-12.78%)
Mutual labels:  orm, database
Elasticsearch
The missing elasticsearch ORM for Laravel, Lumen and Native php applications
Stars: ✭ 375 (-39.32%)
Mutual labels:  orm, laravel
Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+627.67%)
Mutual labels:  orm, database

(this project is looking for a new maintainer)

Analogue ORM

Latest Stable Version Latest Unstable Version License Build Status StyleCI

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

composer require analogue/orm

See Configuration for more information.

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

Check the Documentation for more details.

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

Version 5.6

  • 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

  • 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 driver.
  • Package auto discovery (L5.5)

Version 5.4

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

Version 5.3

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

Version 5.1

  • Illuminate 5.1 + 5.2 Compatibility.

Version 5.0

  • Analogue version now mirrors illuminate version.

Version 2.1.3

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

Version 2.1

  • 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

  • Laravel 5 Support.

Documentation

Check the wiki for full documentation.

Licence

This package is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].