zendframework/zend-paginator
Abandoned Zend Framework paginator component for splitting data collections into pages and rendering pagination controls. Repository moved to laminas/laminas-paginator; use Laminas for active maintenance and current documentation.
zend-paginator is a lightweight, standalone pagination component originally from Zend Framework (now Laminas). Despite being archived (as of 2019), it remains widely used and stable. To begin:
composer require laminas/laminas-paginator (note: the package was transferred to Laminas).zendframework/zend-paginator, use composer require zendframework/zend-paginator (though migration to Laminas is strongly advised for support).Paginator object and assign a Scan or DbSelect adapter (or custom). For simple cases:
$paginator = new Laminas\Paginator\Paginator(
new Laminas\Paginator\Adapter\ArrayAdapter($data)
);
$paginator->setCurrentPageNumber($page);
$paginator->setItemCountPerPage(10);
ArrayAdapter, DbSelect, DbTableSelect) or implement AdapterInterface for custom sources (e.g., Elasticsearch, GraphQL).PaginatorFactory) that inject adapters and page parameters from request.->getPages() for partial rendering (pages, next/prev, ranges) and ->toArray() for JSON APIs. Templates typically loop foreach ($paginator as $item).DbSelect caching via Zend\Db\ResultSet\ResultSet or custom caching in paginateItems()).laminas/laminas-paginator immediately (same namespace, just Laminas\*).DbSelect is powerful but requires manual SQL; for ORMs like Doctrine, avoid direct DB queries—implement a custom adapter that accepts a QueryBuilder and fetches count/offset separately.count() on large datasets can be slow. Always use count() caching or precompute totals (e.g., via separate SELECT COUNT(*)).setItemCountPerPage(0) or negative, pagination breaks silently—validate inputs.setCurrentPageNumber() with non-integer values (e.g., strings) silently defaults to page 1; cast to int.Laminas\Paginator\Paginator::createItems() for custom item slicing (e.g., for cursor pagination). For full cursor-based pagination (e.g., ?cursor=abc), consider using a custom adapter or supplement with laminas/laminas-paginator’s LimitCount pattern.How can I help you explore Laravel packages today?