Download the PHP package andrewdalpino/dataloader-php without Composer

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

DataLoader PHP

A thin caching and data access layer that goes over your existing storage layer and infrastructure. DataLoader PHP uses buffering and cache memoization to optimize requests to the storage layer, prevent overfetching, and prevent N+1 access pattern issues. Based on the Facebook Javascript reference implementation.

Features

Installation

Install DataLoader PHP using composer:

Getting Started

First, you need to create a batch function that will perform the duty of fetching the buffered entities from storage (Redis, REST endpoint, etc.) when necessary. The batch function takes an array of buffered keys as its only argument and must return an array or iterable object.

Optionally, you can specify a cache key function that tells DataLoader how to key the loaded entities. The cache key function takes the $entity to be keyed as an argument as well as its index in the returned array. If you do not specify a cache key function then DataLoader will attempt to use $entity->id, $entity['id'], or fallback to the index of the returned array.

Example

The following is an example of how you could build a User loader in Laravel using an Eloquent model as the fetching API.

Usage

First you must buffer the keys of the entities you wish to load in the future by calling the batch method on the DataLoader object. The batch() function takes either a single integer or string $key or an array of $keys and will tell DataLoader to hold them in the buffer until the next load() operation is called.

It is important to call batch() on every entity you plan to load during the request cycle. DataLoader will not make additional requests to the storage backend if the keys are not in the buffer.

Once you have finished the batching stage, you may call load() to load the entities by key. The load() and loadMany() methods take a single $key or an array of $keys and return a single entity or an array of entities respectively.

Example

The following example demonstrates how DataLoader could be used in a Webonyx GraphQL resolve function paired with the Webonyx Deferred mechanism to fulfill GraphQL queries. In this example, imagine that the user loader has been built and injected via an application container and accessed by its UserLoader facade.

In this example, whenever the author field on a Post node is requested in a GraphQL query, the UserLoader will batch the user entity supporting that data, and then wait until the resolvers have all been called to fetch the data via the Deferred callback. It is clearer to see how we avoid any N+1 access pattern issues by employing this mechanism.

Loading entities from outside of the batch function

Sometimes, the batch function is not the most efficient route to accessing a particular entity. Under other circumstances, such as non-primary key lookups, it's just not possible.

When you need to load an entity into the cache from another source, other than the batch function, you may do so by calling the prime() method on the data loader instance. The prime() method takes an $entity to be primed as an argument. Each primed entity will be keyed by the same cache key function as the ones loaded with the batch function.

Flushing the cache

You may flush the entire in-memory cache by calling the flush() method on the cache instance.

Runtime Configuration

You can tweak the runtime performance of DataLoader by supplying an array of options as the third parameter to the constructor. The options available are listed below with their default values.

Requirements

License

MIT


All versions of dataloader-php with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.3
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 andrewdalpino/dataloader-php contains the following files

Loading the files please wait ....