choco-code/paginator

There is no license information available for the latest version (dev-main) of this package.

A simple helper to display pagination links

dev-main 2021-08-18 20:06 UTC

This package is auto-updated.

Last update: 2025-04-19 04:28:21 UTC


README

Friendly PHP paginator to paginate everything

This package introduces a different way of pagination handling. You can read more about the internal logic on the given documentation link.

Requirements:

  • PHP >=7.4.

Features:

  • Comming soon

Installation and configuration:

Pretty simple with Composer, run

composer require choco-code/paginator

Configuration & Usage examples

Comming soon

PHP:

<?php declare(strict_types=1);

use ChocoCode\Paginator\Pagination\PaginationRender;
require_once __DIR__ . '/vendor/autoload.php';

$options = PaginationOptionFactory::create(
        'Suivant',//Next page label
        'Précédent',//Previous page label
        'p'//current page query parameter name
);


$paginator = paginator(
    500,//Total items to paginate
    5,//Items displayed per page
    5,//Page range
    request()->query()->getInt('page', 1), //current page
    $options//Options
);

render($paginator, PaginationRender::BOOTSTRAP_V5)
            ->getRendeContent();// get the output result(navigation links)

Pagination templates engine

That could be used out of the box in $templateEngine key:

  • PaginationRender::BOOTSTRAP_V4 (by default)
  • PaginationRender::BOOTSTRAP_V5

View

<?php ?>
<!-- total items count !-->
<div class="count">
   <div class="d-flex">
       <div class="text-primary">Total items : <?= $paginator->getTotalItems() ?>|</div>
       <div class="text-primary">Pages : <?= $paginator->getPageCount() ?>|</div>
       <div class="text-primary">Showing items : <?= $paginator->getItemsPerPage() ?>|</div>
  </div>
</div>
<!-- display navigation !-->
<div class="navigation">
  <?php
       render($paginator, PaginationRender::BOOTSTRAP_V5)
       ->rende();
  ?>
</div>