1. Go to this page and download the library: Download dwalczyk/paginator-bundle 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/ */
dwalczyk / paginator-bundle example snippets
use DWalczyk\Paginator\PaginatorInterface;
#[Route('/users')]
public function __invoke(PaginatorInterface $paginator)
{
$res = $paginator->paginate(
$target = $this->getEm()->createQueryBuilder()->select('u')->from(User::class, 'u'),
$page = 1,
$itemsPerPage = 30
);
dump($res);
}
namespace App\Service;
use DWalczyk\Paginator\DataLoaderInterface;
class SamplePaginatorDataLoader implements DataLoaderInterface
{
public function loadItems(mixed $target, int $offset, int $limit): array
{
// some logic here
}
public function loadTotalCount(mixed $target): int
{
// some logic here
}
}