PHP code example of cocoon-projet / pagination

1. Go to this page and download the library: Download cocoon-projet/pagination library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cocoon-projet / pagination example snippets


// Création d'une configuration
$config = new PaginatorConfig(
    $data,      // Données à paginer (array ou query builder)
    $total,     // Nombre total d'éléments
    'page'      // Paramètre GET pour la page (optionnel)
);

// Configuration des options
$config->setPerPage(10)           // Nombre d'éléments par page
       ->setStyling('basic')      // Style de pagination
       ->setCssFramework('bootstrap5'); // Framework CSS

// Création du paginateur
$paginator = new Paginator($config);

// Récupération des éléments de la page courante
$items = $paginator->items();

// Affichage de la pagination
echo $paginator->render('custom-class');

$config->setCssFramework('bootstrap4');

$config->setCssFramework('bootstrap5');

$config->setCssFramework('tailwind');