Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use efficiently paginate with doctrine in Symfony 2?

I would like to use Doctrine ORM and a pagination method in Symfony. KnpPaginatorBundle looks simple and easy to use. I also use Doctrine repositories because the queries can be easily reused and tested.

This bundle works like others I found. It needs the query builder as parameter. Is there a better way to do this than giving each repository function the paginator as a parameter (or null)? I do not want to paginate every query result so I do not think that the described solution is the best and I am looking for sugestions.

like image 762
Robert Dolca Avatar asked Nov 03 '22 09:11

Robert Dolca


1 Answers

I know two bundles for doing that:

  • https://github.com/KnpLabs/KnpPaginatorBundle
  • https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle

Both can paginate ORM/Query or ORM/QueryBuilder (and more).

like image 82
gagarine Avatar answered Nov 09 '22 08:11

gagarine