Download the PHP package mreschke/repository without Composer

On this page you can find all versions of the php package mreschke/repository. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package repository

mreschke/repository

Introduction

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

The main purpose of this library is to:

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

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

All possible WHERE operators are:

Note != and <> are the same thing

Joins

Relationships

Relationships involve subentities. That is, entities that relate to other entities. This repo system can access subentities in a few ways. One is with a ->join feature. The ->join feature cannot join cross repo and you must always ->select('specific', 'columns') as * is not supported. Another is the ->with feature which is like an application level join and can be used both in lazy and eager modes. The ->with feature is beneficial because you can join cross repository.

To access relationships (subentities) you can use the ->with() keyword or use a custom build entity method. Using the ->with() keyword in the proper place along the chain will cause either a lazy load or an eager load. Lazy loading will run one relationship for each eneity and can be VERY inefficient if handled improperly. Eager loading allows you to pre load all relationships for all entities queried. Eager loading will actually run 2 queries. One for your main entites, and one for your relationships based on an IN statement. These results are then combined in PHP.

You can also ->select() with subentities using the period, ex: ->select('id', 'name', 'address.state') where address is the subentity.

Attributes System

You can store additional attributes (or metadata) about any entity in the system. This is off by default for all entities. See Getting Started for how to setup this up.

Attributes can be both lazy loaded and eager loaded. Be very careful here as using lazy loading improperly is very inefficient.

NOTE: Attributes are meant to be small key/values, not large million line strings. When you load any one attribute, ALL attributes for that entity are also loaded into the same ->attributes property. So having hundreds of small attributes per ONE entity is also not advised. The ->object() system is however designed for unlimited and massive any size objects.

Entity Formatting

Before you insert new entities into the database you can run your array through the entity formatter. This will format each colum based on your store map section. This allows you to uppercase, lowercase, trim...the values before being inserted. If a value exceeds a defined size property, an overflow event is fired, see Events for details.

Deleting Records

Updating Records

Getting Started

This section explains how to setup mreschke/repository. How you can use this system for your own entities.

FIXME: This section is NOT written yet. For now, you can look around in the Fake and Fake2 folders as those are 2 repositories used for testing.

Events

The repository fires many events. All are string based events, not class based. They are string based so they can be separated by entity, much like how eloquent fires events by model name so you can listen to individual models not just all models.

All events are prefixed with repository.yourrepo.yourentity.

Example dynatron/vfi events on a customer entity.

Entity level events:

Store level events:

Listeners

Laravel can listen to wildcard events:

Testing

This is an mrcore module, so mrcore5 is required to run the tests.

I know, never test against an actual database. Well I don't know how to do that yet. My tests are more integration tests rather than unit tests. I use a test.sqlite database and a localhost mongo installation will be required. I automatically append the proper database connection information at run-time so no need to adjust config/database.php. The sqlite database is excluded from git and mongo is cheap, you can delete the fake*-repository database if needed.

Seed once...test anytime

Fake/Database/create
./test

Why Was this Written

FIXME: This is NOT complete

Back in 2015 repositories were all the range in the Laravel community. Their benefits were obvious but their implementation was verbose, cumbersome and not as easy to "query build" like eloquent.

Most people like the idea of having a repository layer just in case they ever decide to swap out the backend. The problem for most people is that engineering for the future of backend changes is often a waste of time and considered over engineering. This wasn't true for my case as I was currently in the middle of re-writing all of my software from MSSQL into MySQL and MongoDB. This was a 5 year chess game and required some apps to run with legacy MSSQL backend while others would run with new MySQL backends. These backend were temporary and moving and migrating monthly during this transition phase. This meant I was forced to think "API first". In other words, I didn't need to care where my data currently was and where it was going to end up. All I needed to think about was how I wanted to interact with my data in an ideal world. The repository pattern allowed me to build beautiful APIs into my data even though the backend was MSSQL garbage. Instead of legacy columns like users_first_name I could map that to simply $user->name, something eloquent does not provide.

So if your database looks like this

Table: tblContacts
---------------
contact_id
first_name
last_name
email

Table: tblAddresses
-------------------
address_id
address
zip_code

You can build perfectly mapped (translated) entities that look like this

// We don't want to use the word contacts or tblContacts, we want to use 'users'
// And we don't want first_name, we want firstName...thus the entity mapper
var_dump( $this->vfi->user->find(1)->with('address') )
Mreschke\Vfi\User {
    id: 1
    firstName: "Matthew"
    lastName: "Reschke"
    email: "[email protected]"
    address: {
        id: "3212"
        address: "Some address"
        zip: 75067
    }
}

These now perfeclty mapped entities also act like plain old PHP objects. Meaning you can var_dump() or dd() or dump() them in PHP and get very nice looking results, instead of like Eloquent or Query builder where you get a million other Laravel properites along with it. This gives you clean dumps, which are a huge benifit!

Not only are our entities now perfectly and consistently mapped for output, we can also reliably query on those perfectly mapped columns too!

Of course, since your entities are just plan old PHP objects, you can add any other methods or properties you choose as helpers. Like if you wanted a byName helper, just add it to your entity

Dev Notes

HTTP Store

If I build an HTTP JSON store, what would the URL's look like for full query builder usage?

Since this is public HTTP API, I need to always know context, like WHO is the logged in user that is querying the API. Becuase if they call users/179 I need to know the calling $user actually has access to user 179 etc... In PHP based library this is not a problem becuase I am the once calling the API. But if HTTP, then anyone can call it

all() http://iam/user http://iam/user/byUser(179) http://iam/user/managersByDealer(5975)

where() http://iam/user/where('disabled',true) http://iam/user/where('disabled',true)/where('id','>',100)

order() http://iam/user/orderBy('id') http://iam/user/where('disabled',true)/orderBy('id')

find() http://iam/user/179 http://iam/client/byExtract(4345) http://iam/client/whereHostname('bgmo')/orderBy('id')

Methods http://iam/user/179/types http://iam/user/179/apps http://iam/user/179/hasPerm('admin') http://iam/user/179/isEmployee http://iam/client/accessibleBy(179)

Relationships http://iam/client/179/with('host','address') http://iam/client/179/host http://iam/client/179/address


All versions of repository with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mreschke/repository contains the following files

Loading the files please wait ....