Description
Description
My request is about the possibility of adding a paginator component to quickly create pagination for entities without requiring third party bundle. Other framework like Laravel, CakePHP or ZF have their own build in pagination system so, why not Symfony ?
I know there is some great community bundle to do that, like KnpPaginatorBundle but i think a framework like Symfony should not depend on a third bundle for this kind of feature, even if this bundle is actively maintain.
Finally, when i was searching for informations about pagination in Symfony, i was quiet surprised to see there is nothing about that in the official documentation, except some references to EasyAdminBundle which is not really related to the topic. Maybe it could be usefull to add a note about that in the doc ? Even if it's to redirect developers to community bundles. But this should probably be discussed in a new issue on the documentation repository.
Example
Here is a quick example for what i have in mind
<?php
namespace App\Controller;
use App\Repository\BlogRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
class BlogController extends Controller
{
/**
* @Route("/blog/{page}", name="blog_list", requirements={"page"="\d+"})
*/
public function index(int $page = 1, BlogRepository $blogRepository)
{
$query = $articleRepository->findAll();
$maxResult = 10;
return $this->render('blog/index.html.twig', [
'articles' => $this->paginate($query, $page, $maxResult)
]);
}
}