Skip to content

[RFC] Paginator component #27276

Closed
Closed
@ker0x

Description

@ker0x

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)
        ]);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions