microparts / paginateformatter-php
This package is abandoned and no longer maintained.
No replacement package was suggested.
Pagination format for spacetab.io standards.
1.1.1
2020-01-13 16:52 UTC
Requires
- ext-pdo: *
- pagerfanta/pagerfanta: ^2.1
Requires (Dev)
- amphp/postgres: ^1.1
- envms/fluentpdo: ^2.1
- phpstan/phpstan: ^0.12.5
- phpunit/phpunit: ^8
- symfony/var-dumper: ^5.0
README
THIS PACKAGE PERMANENTLY MOVED TO https://github.com/spacetab-io/pagerfanta-adapt-php
This a simple formatter based on Pagerfanta library. Specially created for follow up corporate standards of pagination format.
Installation
composer install microparts/paginateformatter-php
Usage
Basic:
use Pagerfanta\Adapter\ArrayAdapter; use Pagerfanta\Pagerfanta; use Microparts\PaginateFormatter\PaginateFormatter; $adapter = new ArrayAdapter($array); $pagerfanta = new Pagerfanta($adapter); $paginate = new PaginateFormatter($pagerfanta); $paginate->format(); // returns formatted output.
Replace current page results from Pagerfanta:
use Pagerfanta\Adapter\ArrayAdapter; use Pagerfanta\Pagerfanta; use Microparts\PaginateFormatter\PaginateFormatter; $adapter = new ArrayAdapter($array); $pagerfanta = new Pagerfanta($adapter); $paginate = new PaginateFormatter($pagerfanta); $paginate->setItems($transformedModel)->format();
Depends
- >= PHP 7.1
- Composer for install package
Additional adapters
This package also add a new following adapters:
Microparts\PaginateFormatter\Adapters\BasePdoAdapter.php
Microparts\PaginateFormatter\Adapters\FluentPdoAdapter.php
Microparts\PaginateFormatter\Adapters\PaginatePdoAdapter.php
Output format
{ "data": [{"foo": "bar"}], "meta": { "pagination": { "total": 6, "per_page": 1, "current_page": 1, "total_pages": 6, "prev_page": null, "next_page": 2 } } }
License
GNU GPL v3