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 Laravel Package

metaship-ru/knp-paginator-bundle

Symfony bundle that adds pagination to Doctrine ORM/ODM queries and renders page controls through Twig. Provides a paginator service, pageable query helpers, and configurable Bootstrap-friendly templates for building paginated listing pages. A metaship-ru fork of KnpPaginatorBundle.

View on GitHub
Deep Wiki
Context7

Getting Started

This is the first assessment for this package; the 0.1.3 release pins the transitive dependency knplabs/knp-components to exactly 2.3.4.

  • Install with composer require <vendor>/<package>:^0.1.3. The pin is applied transitively, so you do not need to add knplabs/knp-components yourself.
  • Start by reading composer.json (to see the 2.3.4 constraint and the PHP requirement it implies), then src/ for the service provider and any paginator adapter, then config/ if a config file is published.
  • If the package ships a service provider with auto-discovery, no manual registration is needed; otherwise add it to config/app.php providers.
  • First use case: paginate an Eloquent/query-builder result through the package's adapter and render page links, confirming the returned page/per-page values match what request()->input('page') supplies.
  • Verify the pin landed correctly with composer show knplabs/knp-components — you should see 2.3.4 and not 3.x.

Implementation Patterns

  • Constructor injection over facades. Resolve the paginator/adapter through the container so tests can swap in a fake or a fixed per-page value.
  • Config-driven page size. Read per-page limits and the page query-string key from config/<package>.php rather than hard-coding, then override per environment.
  • Adapter wrapping. If the package exposes a Knp-backed adapter, wrap it behind your own interface so a future unpin or a move to Laravel's native paginator is a one-class change.
  • Composer constraint hygiene. Because the pin is transitive, treat knplabs/knp-components as part of your dependency surface: run composer why knplabs/knp-components before adding any pagination-adjacent package, and lock the root project so CI and production resolve identically.
  • Upgrade workflow. On each patch release, run composer update <vendor>/<package> --with-dependencies, then diff composer.lock for the knp pin and review the test suite before merging.
  • Testing pattern. Assert on page counts, boundary pages (first/last, out-of-range page), and empty result sets — these are where paginator adapters usually break.

Gotchas and Tips

  • The pin is a compatibility guard, not a feature. Pinning to 2.3.4 almost certainly avoids a 3.x breaking change or PHP-version bump. Expect composer update to refuse to move it, and don't "fix" that by editing the constraint.
  • Conflict resolution. If another dependency requires knplabs/knp-components:^3.0, Composer will fail to resolve. Use composer why-not knplabs/knp-components 2.3.4 to identify the conflicting package before considering a fork or --with-all-dependencies.
  • Do not pin in your root composer.json. Adding your own "knplabs/knp-components": "2.3.4" hides the package's intent and will silently block future releases that relax the pin. Let the package own it.
  • Out-of-range pages. Many paginator adapters return an empty set rather than clamping; validate page to >= 1 and clamp to the last page in your controller or request class.
  • Security surface. The page parameter flows into offset math — cast to int and bound it (e.g. max:10000) to prevent absurd offsets or negative values reaching the query.
  • Debugging. Enable query logging around the paginate call to confirm the LIMIT/OFFSET values; if counts and rows disagree, the issue is usually a groupBy or having interacting with the adapter's count query.
  • Extension points. Prefer publishing/overriding the config and binding a custom adapter implementation over editing vendor code — vendor edits vanish on the next composer install.
  • Release cadence. At 0.x, treat patch releases as potentially behavioural. Read the release notes for dependency-pin changes like this one, since they can alter runtime PHP constraints without any source change.
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.
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
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