Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Knp Paginator Bundle

Knp Paginator Bundle Laravel Package

knplabs/knp-paginator-bundle

Friendly Symfony paginator that paginates everything. Built on the Knp Pager component, it offers customizable pagination views, event subscribers, plus filtering and sorting, with no adapter setup required. Supports Symfony 6.4+, Twig 3, and ORM/ODM queries.

View on GitHub
Deep Wiki
Context7

KnpPaginatorBundle is a friendly Symfony paginator that lets you paginate virtually anything, built on the Knp Pager component. It separates concerns cleanly: the paginator generates the pagination view, while templates handle presentation. Compatible with Symfony >=6.4, Twig >=3.0, and Knp Pager >=4.4, it also supports the Translation component for its bundled templates.

  • No adapter initialization required—works out of the box
  • Customizable pagination views, templates, and event subscribers
  • Custom filtering and sorting via request parameters
  • Multiple paginators supported through aliases
  • Easy installation via Composer with simple YAML configuration
Frequently asked questions about Knp Paginator Bundle
Does KnpPaginatorBundle work with Laravel?
No, not natively. KnpPaginatorBundle is a Symfony bundle built on the Knp Pager component and requires a Symfony 6.4+ kernel, Twig, and typically Doctrine ORM or ODM. A pure Laravel app has none of those pieces wired together, so you would have to build a compatibility layer that translates Knp's PaginationInterface and PaginationView into Laravel's LengthAwarePaginator. For Eloquent-backed Laravel projects the integration cost is high and the payoff is negligible.
How do I install KnpPaginatorBundle?
Install it with Composer using composer require knplabs/knp-paginator-bundle. If you use Symfony Flex the bundle is registered automatically; otherwise add Knp\Bundle\PaginatorBundle\KnpPaginatorBundle to your bundle registration file. Keep the knp-components package in sync with the bundle version, since the bundle depends on Knp Pager 4.4 or higher.
What PHP, Symfony, and Twig versions does KnpPaginatorBundle require?
The current master branch targets Symfony 6.4 and newer, and Twig 3.0 or newer if you use the provided templates. Version 6.11.0 dropped PHP 8.1 support, so PHP 8.2 is now the minimum runtime. If you need the Translation-powered templates you must also have the Symfony Translation component installed.
Can KnpPaginatorBundle paginate Eloquent queries instead of Doctrine?
There is no Eloquent adapter. The bundle ships subscribers for Doctrine ORM and ODM queries plus plain arrays, and its advanced features such as output walkers and the wrap_queries option are Doctrine-specific. To paginate Eloquent you would write a custom subscriber or, far more simply, use Laravel's built-in paginator.
How does KnpPaginatorBundle compare to Laravel's LengthAwarePaginator?
Laravel's pagination is imperative and tightly coupled to the query builder, Eloquent, and Blade views, while Knp uses a declarative, event-driven model based on PaginatorInterface and PaginationView. Knp's separation of paginator logic from view rendering is clean, but it produces Twig-rendered output that will not drop into Blade without rewrites. For Laravel applications Illuminate\Pagination\LengthAwarePaginator is almost always the cheaper, better-supported choice.
Do I need Twig to use KnpPaginatorBundle's pagination views in Laravel?
The bundle's bundled templates are Twig templates, so they will not render in Blade. You would either add a Twig bridge such as a Laravel Twig package or reimplement the pagination view yourself. Because the paginator only generates a view object, you can bypass Twig entirely and render the data with Blade, but that is custom code you own.
What changed in v6.11.0 and does it affect a Laravel integration?
Version 6.11.0 exposed the wrap_queries default so Doctrine ORM output walkers can be enabled, narrowed the exceptions caught by the bundle's listener, and dropped PHP 8.1 support. All of these changes are Doctrine or Symfony HTTP-kernel concerns and are inert inside Laravel. The one item that matters is the PHP floor: Laravel 10 apps still on PHP 8.1 must stay pinned to v6.10.x, while Laravel 11 and 12 apps on PHP 8.2 or 8.3 are unaffected.
How do I add custom filtering and sorting with KnpPaginatorBundle?
You add custom filtering and sorting by registering event subscribers that hook into the paginator's events, or by using the bundle's request-parameter-driven sort and filter features. Query parameter names such as the page and sort field names are configurable under the knp_paginator key in your configuration. If you run multiple paginators on one page you must assign each an alias so their parameters do not collide.
Can I use KnpPaginatorBundle in a Laravel app that already uses Symfony components?
It is technically possible if your app already pulls in symfony/http-foundation, symfony/routing, or a Twig bridge, because the bundle's core logic is largely framework-agnostic Pager code. In practice you would still need a Laravel service provider, a translating wrapper around PaginationView, and a replacement for the Twig renderer. That is a significant amount of glue code to maintain against a package whose maintainers are investing in the Symfony and Doctrine path.
Is KnpPaginatorBundle actively maintained and production-ready?
Yes for Symfony: it is maintained by KnpLabs with regular releases and CI builds, and it is widely used in Symfony production applications. For Laravel, however, you would own the entire integration layer, including upgrades, template rendering, and event bridging. Note also a release hygiene quirk in v6.11.0 where the changelog compare link pointed at an earlier tag, so verify the diff before upgrading.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo