1. Go to this page and download the library: Download ruvents/paginator 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/ */
ruvents / paginator example snippets
use Ruwork\Paginator\PaginatorBuilder;
use Ruwork\Paginator\Provider\IterableProvider;
$data = range(1, 100);
$paginator = PaginatorBuilder::create()
// )
// defaults to 2
->setProximity(1)
// defaults to 10
->setPerPage(3)
->getPaginator();
// template logic
foreach ($paginator->getItems() as $item) {
// render the item row
}
if (null !== $previous = $paginator->getPrevious()) {
echo sprintf('<a href="?page=%d">Previous</a>', $previous->getNumber());
}
foreach ($paginator as $section) {
foreach ($section as $page) {
echo sprintf('<a href="?page=%1$d" class="%2$s">%1$d</a>', $page->getNumber(), $page->isCurrent() ? 'active' : '');
}
}
if (null !== $next = $paginator->getNext()) {
echo sprintf('<a href="?page=%d">Next</a>', $next->getNumber());
}
use Ruwork\Paginator\PaginatorBuilder;
use Ruwork\Paginator\Provider\DoctrineOrmProvider;
use Doctrine\ORM\EntityRepository;
/** @var EntityRepository $repository */
$qb = $repository->createQueryBuilder('entity')
->andWhere('entity.id = :id')
->setParameters([
'id' => 1
]);
$paginator = PaginatorBuilder::create()
->setProvider(new DoctrineOrmProvider($qb))
->getPaginator();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.