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

Stand-Alone

The paginator can be used stand-alone, outside a Mezzio or laminas-mvc application.

The example uses the following directory structure:

example-app/
|-- public/
|   `-- index.php
`-- vendor
    `-- …

Create and Configure Paginator

Create a paginator and a related adapter, set the item count for one page and the current page number in public/index.php:

// Create paginator
$paginator = new Laminas\Paginator\Paginator(
    new Laminas\Paginator\Adapter\ArrayAdapter($albums)
);

// Configure paginator
$paginator->setItemCountPerPage(4);
$paginator->setCurrentPageNumber((int) ($_GET['page'] ?? 1));
$albums = [
    [
        'artist' => 'David Bowie',
        'title'  => 'The Next Day (Deluxe Version)',
    ],
    [
        'artist' => 'Bastille',
        'title'  => 'Bad Blood',
    ],
    [
        'artist' => 'Bruno Mars',
        'title'  => 'Unorthodox Jukebox',
    ],
    [
        'artist' => 'Emeli Sandé',
        'title'  => 'Our Version of Events (Special Edition)',
    ],
    [
        'artist' => 'Bon Jovi',
        'title'  => 'What About Now (Deluxe Version)',
    ],
    [
        'artist' => 'Justin Timberlake',
        'title'  => 'The 20/20 Experience (Deluxe Version)',
    ],
    [
        'artist' => 'Bastille',
        'title'  => 'Bad Blood (The Extended Cut)',
    ],
    [
        'artist' => 'P!nk',
        'title'  => 'The Truth About Love',
    ],
    [
        'artist' => 'Sound City - Real to Reel',
        'title'  => 'Sound City - Real to Reel',
    ],
    [
        'artist' => 'Jake Bugg',
        'title'  => 'Jake Bugg',
    ],
];

Output Pure Data

The data of each sub-array is returned by iteration over the paginator:

foreach ($paginator as $item) {
    var_dump($item['artist']); // "Bon Jovi", "Justin Timberlake", …
    var_dump($item['title']); // "What About Now (Deluxe Version)", "The 20/20 Experience (Deluxe Version)", …
}

Retrieving the current status data of the paginator:

var_dump($paginator->getPages()->previous); // 1
var_dump($paginator->getPages()->next); // 3
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai