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.
composer install microparts/paginateformatter-php
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();
- >= PHP 7.1
- Composer for install package
This package also add a new following adapters:
Microparts\PaginateFormatter\Adapters\BasePdoAdapter.php
Microparts\PaginateFormatter\Adapters\FluentPdoAdapter.php
Microparts\PaginateFormatter\Adapters\PaginatePdoAdapter.php
{
"data": [{"foo": "bar"}],
"meta": {
"pagination": {
"total": 6,
"per_page": 1,
"current_page": 1,
"total_pages": 6,
"prev_page": null,
"next_page": 2
}
}
}
GNU GPL v3