PHP code example of phpsoftbox / pagination

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

    

phpsoftbox / pagination example snippets




use PhpSoftBox\Pagination\Paginator;
use PhpSoftBox\Pagination\RequestPaginationContextResolver;

$resolver = new RequestPaginationContextResolver($request);

$paginator = new Paginator(perPage: 20, resolver: $resolver);
$paginator = $paginator->appends(['status' => 'active']);

$result = $paginator->make(
    items: $items,
    total: 120,
    page: 2,
);

$payload = $result->toArray();