Download the PHP package paysera/lib-pagination without Composer

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

Paysera Pagination component

Latest Version on Packagist Build Status Coverage Status Quality Score Total Downloads

This component allows to paginate Doctrine QueryBuilder instances using cursor-based pagination. Offset is also supported.

Why?

Performance

Cursor pagination can be much more efficient under large data-sets.

For example, to take 3000th page, consisting of 100 items, using offset you would need to execute such query:

This type of query, even if you have indexes on the fields you are querying by (and the fields you order by), would need to iterate over 29900 items first, before giving you the requested result.

If using cursor based pagination, the resulting query can look like this:

This allows to add required indexes to the table to enable fast querying. Keep in mind that without any indexes, the performance can be really similar.

In this concrete example, there should be a multiple-column index on field,created_at,id for best performance (or just field,created_at if created_at is rather unique).

Iterate over all the items

When using query from previous example with offset based pagination, it's possible to get the same item twice or miss some of the items.

This is because when we're getting the pages, new items can be added or some of the items removed, which changes the position of all other items.

Let's take an example. We have pages, each of 5 items. We've already got the first page with items 1 2 3 4 5. Before we get the second page, these situations might occur:

If we're using cursor based pagination, we start the page after (including or excluding) or before some concrete item, so we don't get these types of issues.

Caveats

Using cursors, it's easy to move to the next and previous pages, but it's not possible to:

To support mixed cases:

Installation

Basic Usage

Use ResultProvider class (service) to provide the result.

To get the result, two arguments are needed:

Generally ConfiguredQuery holds internals related to QueryBuilder so it's recommended to return this from the Repository directly – let's hold implementation details together.

Pager should be created somewhere in the input layer, usually in the controller or similar place.

Example usage:

Using iterator

There are a few classes (services) to help iterating over large result sets:

Using ResultIterator:

Using FlushingResultIterator:

If there was out of memory exception etc, search logs (INFO level) for last "Continuing with iteration" message, look at "after" in the context, then:

Semantic versioning

This library follows semantic versioning.

See Symfony BC rules for basic information about what can be changed and what not in the API.

Running tests

Contributing

Feel free to create issues and give pull requests.

You can fix any code style issues using this command:


All versions of lib-pagination with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1|^8.0
doctrine/orm Version ^2.5
psr/log Version ^1.0|^2.0
symfony/property-access Version ^3.0|^4.0|^5.0|^6.0
ext-json Version *
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 paysera/lib-pagination contains the following files

Loading the files please wait ....