Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Paginator Laravel Package

laminas/laminas-paginator

Laminas Paginator provides flexible pagination for PHP apps, with adapters for arrays, iterators, and database results. Generate page ranges and navigation data, and integrate with Laminas MVC or use standalone for paged listings.

View on GitHub
Deep Wiki
Context7

Configuration

Laminas\Paginator is designed to work with laminas-servicemanager as its dependency injection container.

It is perfectly possible to use Paginator without using Laminas Service Manager as the DIC in your project, but some convenience will be sacrificed.

Configuring Pagination Defaults

The following configuration would be returned as part of the config service returned from the DI container, so it would be inserted into a PHP file that is autoloaded during bootstrap, or in a ConfigProvider perhaps:

return [
    'paginator' => [
        'itemCountPerPage' => 10,
        'pageRange'        => 10,
        'scrollingStyle'   => 'Sliding',
    ],
];

The above configures the default page size to 10, the default page range to 10 and uses the Sliding scrolling style by default.

The Paginator Factory Service

In order for these defaults to apply to newly created paginators, you must use the PaginatorFactory service to delegate construction of your paginators:

Create a Paginator by Providing a Concrete Adapter

use Laminas\Paginator\Adapter\ArrayAdapter;
use Laminas\Paginator\PaginatorFactory;

$factory = $container->get(PaginatorFactory::class);
$paginator = $factory->withAdapter(new ArrayAdapter([1, 2, 3]));
// The paginator above will now be configured with the defaults you have specified.

By using the PaginatorFactory, you can ensure consistent configuration of paginators across your application with a single place where these defaults can be changed, instead of hard-coding preferences into every call to new Paginator(...).

The factory has 2 more methods for building paginators:

Create a Paginator by Providing Configuration for an Adapter

use Laminas\Paginator\Adapter\ArrayAdapter;
use Laminas\Paginator\PaginatorFactory;

$factory = $container->get(PaginatorFactory::class);
$paginator = $factory->buildAdapter(ArrayAdapter::class, ['some', 'items', 'to', 'paginate']);

Create a Paginator with an Iterable

use Laminas\Paginator\Adapter\ArrayAdapter;
use Laminas\Paginator\PaginatorFactory;

$factory = $container->get(PaginatorFactory::class);
$paginator = $factory->withItems(['some', 'items', 'to', 'paginate']);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport