What is correct way to use Pagerfanta for pagination in Symfony2 What is correct way to use Pagerfanta for pagination in Symfony2 symfony symfony

What is correct way to use Pagerfanta for pagination in Symfony2


I think your application doesn't know how to parse ?page=2 to the controller action.

Include a {page} in your route (as @AdrienBrault replied), which you wish to have pagination.

like this:

my_index:  pattern:  /{page}  defaults: { _controller: MyTestBundle:Object:index, page: 1 }  requirements:    _method:  GET    page: \d+

PagerFantaBundle will (I guess) try to guess the correct route.

Worked for me.


I had to use 'currenPage' instead fo 'page' in my routing and I found a way to do this :

{{ pagerfanta(pager, 'my_pager_view', {'pageParameter':'[currentPage]'}) }}