PHPackages                             mreschke/repository - 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. mreschke/repository

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

mreschke/repository
===================

Mreschke Repository and Entity Manager

5.3.14(1y ago)02.1kMITPHP

Since Dec 23Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (27)Used By (0)

mreschke/repository
===================

[](#mreschkerepository)

- [Introduction](#introduction)
- [Basic Usage and Syntax](#usage)
- [Getting Started](#started)
- [Events](#events)
- [Testing](#testing)
- [Why Was this Written](#why)

Introduction
============

[](#introduction)

A Laravel based active records style entity mapper repository system for all your backends.

*The main purpose of this library is to:*

- Provide beautiful plain-old-php dumps of your entities. Ever dump an eloquent model? Ugly and HUGE.
- Provide entity column mapping (map `some_ugly_old_column` in your database to `->perfectColumn` in PHP)
- Provide full eloquent style query builder but based on `->where('perfectColumn')` not `some_ugly_old_column` like eloquent...entity mapping everywhere!
- Provide relationships and `->with()` capability with single lazy loading or bulk eager loading capabilities even across repositories and datacenters.
- Provide active records `->save()` and `->delete()` syntax but yet still on top of beautifully dumped plain-old-php objects (wait what!?!..yeah IoC based singleton caching man)
- Provide ability to swap repository backends on the fly via `$myApp->connection('otherBackend')`
- Provide repo level formatting and constraints like uppercase, lowercase, ucwords, trim, required, default value along with datatype size overflow detection.
- Provide versioned entity mapping. Ever use  as JSON API transformers for your model? By nature, this entity mapper already does that transformation, but even allows you to version your entity maps for this very reason! Already mapped it once, why map it again in your REST API?
- Allow cross repository JOINS, even if repositories are on a different server or even a different network/datacenter.
- Provide a fully capable attributes system. Ever want to store additional columns or metadata about a row, but don't want to add another column? Every entity row can have as many additional attributes as you want. You can even `->whereAttribute()` to find entities based on attributes!
- Provide a fully capable object storage system. Similar to attributes (arbitrary values stored on an entity), but capable of massive size (files, notes, json blobs). Attributes are for small key/value items, objects are for everything else.

Basic Usage and Syntax
======================

[](#basic-usage-and-syntax)

In my examples, I have an application called VFI which has users, dealers, ros, items. This imaginary entity will be accessed via `$this->vfi` for these examples.

Getting Records
---------------

[](#getting-records)

*NOTE:* `->all()` and `->get()` are identical and can be used interchangeably

```
