Right away I would say, that I read this question Doctrine2 Paginator, but it doesn\'t give me enough information regarding the title of my question.
When I used Doctrin
The paginator usage is as following:
$paginator = new \Doctrine\ORM\Tools\Pagination\Paginator($query);
$totalItems = count($paginator);
$pagesCount = ceil($totalItems / $pageSize);
// now get one page's items:
$paginator
->getQuery()
->setFirstResult($pageSize * ($currentPage-1)) // set the offset
->setMaxResults($pageSize); // set the limit
foreach ($paginator as $pageItem) {
echo "- " . $pageItem->getName() . "
";
}