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

Paginator Laravel Package

ecommit/paginator

Lightweight PHP paginator for arrays or ArrayIterator. Configure page, max_per_page, and data; optionally provide total count for large datasets. Iterate results, get last page, and use count() to know items on the current page.

View on GitHub
Deep Wiki
Context7

Paginator

Create a paginator.

Tests

Installation

To install paginator with Composer just run :

$ composer require ecommit/paginator

Usage

use Ecommit\Paginator\ArrayPaginator;

//Create a paginator
$paginator = new ArrayPaginator([
    //Options
    'page' => 1,
    'max_per_page' => 100,
    'data' => ['val1', 'val2', 'val3'],
    //Or with an ArrayIterator
    //'data' => new \ArrayIterator(['val1', 'val2', 'val3']),
]);

$totalPages = $paginator->getLastPage();
$countRows = \count($paginator);
foreach ($paginator as $result) {
    //...
}

Available options

Option Type Required Default value Description
page Integer No 1 Current page
max_per_page Integer No 100 Max elements per page
data Array or ArrayIterator Yes If count option is null : All data (of all pages)If count option is not null : Only the data to display on the current page
count Integer or null No Null You can use this option when the data volume is too large. If the value is not null :It must equal the total number of resultsThe data option must contain only the data to display on the current page

Available methods

See API documentation

License

This librairy is under the MIT license. See the complete license in LICENSE file.

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.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views