PHP code example of microweber-packages / microweber-pagination

1. Go to this page and download the library: Download microweber-packages/microweber-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/ */

    

microweber-packages / microweber-pagination example snippets


use MicroweberPackages\Pagination\Paginator;

// Basic usage
$paginator = new Paginator([
    'currentPage' => 5,
    'lastPage'    => 100,
    'baseUrl'     => url('/items'),
    'theme'       => 'bootstrap',
    'size'        => 'md',
    'onEachSide'  => 5,
]);

echo $paginator->render();

// Fluent API
$paginator = (new Paginator())
    ->currentPage(50)
    ->lastPage(1000)
    ->baseUrl('/products')
    ->theme('tailwind')
    ->size('lg')
    ->onEachSide(5)
    ->customClasses(['active' => 'bg-indigo-500 text-white']);

echo $paginator;

// From Laravel paginator
$laravelPaginator = Product::paginate(15);
$paginator = Paginator::fromLaravel($laravelPaginator, [
    'theme'     => 'bootstrap-flex',
    'onEachSide' => 3,
]);

// View override from template
$paginator = new Paginator([
    'currentPage' => 5,
    'lastPage'    => 100,
    'baseUrl'     => '/items',
    'view'        => 'templates.my-theme.pagination',
]);
bash
php artisan vendor:publish --tag=mw-pagination-config