Download the PHP package olliecodes/eloquent-identity without Composer

On this page you can find all versions of the php package olliecodes/eloquent-identity. 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 eloquent-identity

Eloquent Identity

Latest Stable Version Latest Unstable Version License Scrutinizer Code Quality

Eloquent identity provides a cache on top of Eloquent preventing multiple models being created for a single database row using the Identity Map design pattern (P of EAA & Wikipedia).

Table of Contents

Installing

To install this package simply run the following command.

This package uses auto-discovery to register the service provider but if you'd rather do it manually, the service provider is:

There is no configuration required.

Usage

To make use of the Eloquent identity map on your models, add the following trait.

Finding

Any calls to find(), findOrFail() or findOrNew() on a model that uses this trait, will skip the query if a model has already been created using the provided id.

Calls to findMany() will skip any ids that have already been used, only querying ones that are not present in the cache.

The query is only skipped if there are no where clauses, joins or having statements.

If you wish to force the query, you can call refreshIdentityMap() on the query builder instance. If you wish to skip the query on a builder instance where refreshIdentityMap() has been called, you can call useIdentityMap().

Hydrating

When the query builder attempts to create a new instance of a model using this trait, with a key that matches an already existing instance of the model, the existing instance will be used.

If the model is using timestamps, and the returned attributes are newer, the attributes on the existing instance will be updated, but will retain any changes you'd previously made.

BelongsTo

If a belongs to relationship is loaded (not belongs to many) without constraints and without refreshIdentityMap() being called, the query will skip any model instances that already exist.

Flushing

If you wish to flush the cached models, call flushIdentities() on an instance of IdentityManager, or on the Identity facade.

How

The IdentityManager stores an array containing all existing model instances and their identity.

The identities for models are stored as string, created using the following class.

This contains a key, the model class name, and the connection name. The string version of these looks like so:

Why

It's very easy to end up with multiple versions of the same model, meaning that updates on one aren't persisted to others.

Eloquent identity was created to reduce the number of models created, help limit unnecessary queries, and allow for consistent model interaction. It doesn't matter where in your code you're dealing with user 1, any changes made during a request will persist across all instances.


All versions of eloquent-identity with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 | ^8.0
laravel/framework Version ^7 || ^8
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 olliecodes/eloquent-identity contains the following files

Loading the files please wait ....