Download the PHP package esi/pagination without Composer

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

Pagination

Build Status Code Coverage Scrutinizer Code Quality Tests PHPStan Psalm Static analysis Type Coverage Psalm Level Latest Stable Version Downloads per Month License

Pagination library that implements a paging interface on collections of things.

Acknowledgements

This library is a fork of the AshleyDawson\SimplePagination(https://github.com/AshleyDawson/SimplePagination) library by Ashley Dawson(https://github.com/AshleyDawson).

To see a list of changes in this library in comparison to the original library, please see the CHANGELOG.md file.

Installation

You can install Pagination via Composer. To do that, simply require the package in your composer.json file like so:

Then run composer update to install the package.

How Pagination Works

I've tried to make Pagination as simple, flexible, and easy to use as possible. There are four main elements that describe the operation of Pagination. These are:

The Paginator service performs the pagination algorithm, generating the page range and item collection slices. When it's done, it will return a Pagination object filled with the item collection slice and metadata.

The two main operations the Paginator service will perform on your collection (or data set) are denoted by two callback methods passed to the Paginator service. The first one is the Item total callback. This callback is used to determine the total number of items in your collection (returned as an integer). The second one is the Slice callback. This callback actually slices your collection given an offset and length argument.

The idea behind using these callbacks is so that Pagination is kept, well, simple! The real power comes with the flexibility. You can use Pagination with just about any collection you want. From simple arrays to database lists to Doctrine collections to Solr result sets - we've got you covered! It really doesn't matter what we paginate - as long as it's a collection of things, and you can count and slice it.

Basic Usage

Ok, lets go with the most basic example - paginating over an array.

There are lots of other pieces of metadata held within the pagination object. These can be used for building first, last, previous and next buttons.

MySQL Example

Let's take the example above and use a MySQL result set instead of an array.

Note: The example above uses mysqli etc. as I tried to make it as simple as possible. In the real world please use PDO, Doctrine DBAL, etc.

It really doesn't matter what sort of collection you return from the Paginator::setSliceCallback() callback. It will always end up in Pagination::getItems().

Constructor Configuration

You can also configure the paginator with a configuration array passed to the constructor. For example:

Pagination as an Iterator

The Pagination object returned from the Paginator service implements \IteratorAggregate and \Countable so you can do things like this in your view:

Arbitrary Pagination Metadata

During both item total and slice callbacks you have the option of passing arbitrary metadata to the pagination object. This is an optional feature and is useful if you have a use-case where additional data is returned by these operations, and you want to access it from the pagination object whilst listing the items. A good example of this is when using search engines such as ElasticSearch, you can pass back secondary information - like aggregations, etc. A generic example can be seen below:

Pre- and Post-Query Callbacks

Before and after the count and slice queries, you can set callbacks to fire. To set them, do the following:

This is handy if you want to perform some function before and after each query is made.

Pagination Object

The result of the Paginator::paginate() operation is to produce a Pagination model object, which carries the item collection for the current page plus the meta information for the collection, e.g. pages array, next page number, previous page number, etc.

Please see below for a list of properties that the Pagination object has.

A good example of using the Pagination object is to build a simple pagination navigation structure:

About

Requirements

Submitting bugs and feature requests

Bugs and feature requests are tracked on GitHub

Issues are the quickest way to report a bug. If you find a bug or documentation error, please check the following first:

Contributing

See CONTRIBUTING

Author

Eric Sizemore - https://www.secondversion.com

License

Pagination is licensed under the MIT License - see the LICENSE.md file for details


All versions of pagination with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2 <8.5
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 esi/pagination contains the following files

Loading the files please wait ....