loyaltycorp / easy-pagination
Provides a generic way to handle pagination data from clients
Requires
- php: ^7.1
Requires (Dev)
- laravel/lumen-framework: ^5.5
- phpunit/phpunit: ^7.5
- vlucas/phpdotenv: ^3.3
- dev-master / 0.11.x-dev
- v0.10.7
- v0.10.6
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.11
- v0.7.10
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.0
- v0.6.14
- v0.6.13
- v0.6.12
- v0.6.11
- v0.6.10
- v0.6.9
- v0.6.8
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.1
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.1
This package is auto-updated.
Last update: 2019-11-25 05:32:32 UTC
README
Provides a generic way to handle pagination data from clients.
You are wondering if this package could be useful to you, right? Here are some points to help you find out:
- You have an PHP application
- You have to handle pagination data from your clients
- You are sick of having to resolve the "page" and "perPage" (or however you want to call those parameters) again and again
- Or sick of hearing "The pagination doesn't work for the blog posts comments" and realise you have a typo in "parPage"
- ...
This package provides you with out-the-box tools to implement a generic, centralised and consistent pagination data handling system to keep you away from any troubles :)
Documentation
Installation
The recommended way to install this package is to use Composer.
$ composer require loyaltycorp/pagination
How it works
This package provides different "resolvers" which will extract the pagination data from a request according to your configuration. To guarantee interoperability, the resolvers expect a PSR7 ServerRequestInterface, if your project uses it too then perfect! But no stress if it doesn't you can use the EasyPsr7Factory package which will convert your requests for you!
Resolvers
Can't you find your happiness in the existing resolvers? Please let us know or even better create a PR :)
StartSize Resolvers
The "StartSize" resolvers assume your pagination is based on only 2 attributes to define the start and its size. What
are those attributes names or default values? This is up to you!
A StartSizeConfigInterface
(and its default implementation) is here for you to define all that as you want.
Here are some examples of configuration you can have:
start_attributes | start_default | size_attribute | size_default |
---|---|---|---|
page | 1 | perPage | 15 |
_page | 1 | _per_page | 15 |
number | 1 | size | 15 |
offset | 0 | limit | 30 |