paysera/lib-pagination
A lightweight PHP pagination library from Paysera for splitting data sets into pages. It calculates offsets, page counts, and navigation ranges, helping developers build paginated lists and search results in web applications.
OFFSET performance cliff. This package gives you both cursor and offset modes from one Doctrine QueryBuilder, so you can standardize on one contract without writing cursor encoding/decoding, ordering tie-breakers, and filter-preserving links yourself.QueryBuilder. If the surface in question is Eloquent, it does not apply. If you run Doctrine inside Laravel (e.g., laravel-doctrine) or in a Symfony/standalone PHP service, it is applicable.Consider it when all of the following hold:
QueryBuilder (or you can adapt it), not Eloquent.OFFSET cost or page drift is a real user-visible or cost problem.Look elsewhere when:
cursorPaginate(); adopting Doctrine just to use this library is a bad trade.COUNT(*) on large tables is exactly what you were trying to escape.To executives (one paragraph): We have a recurring, low-glamour problem: list endpoints that paginate by page number break when data changes underneath the user and get slower as users scroll deeper. Fixing it properly is a small but fiddly piece of engineering that we would otherwise rebuild in every service. A focused MIT-licensed library from Paysera — a payments company that has clearly solved this for its own transaction data — already implements both cursor-based and offset-based pagination over Doctrine queries. The recommendation is to adopt it as a narrow, replaceable utility, not a platform commitment: it is small enough to fork if it stalls, and it removes a category of API bugs and a recurring engineering chore. It is not a strategic bet and should not appear on an architecture diagram.
To engineering (the honest version): It does one thing — paginate a Doctrine QueryBuilder — with both cursor and offset modes. Upside: correct cursor semantics without us rediscovering the tie-breaker and filter-preservation edge cases, MIT license, small surface area, cheap to vendor. Downsides: ~14 GitHub stars, essentially single-vendor provenance, and Doctrine-only, so it is inert if this service is Eloquent. Plan to pin the version, vendor or mirror the source, read the implementation before trusting it in a hot path, and wrap it behind our own pagination interface so swapping it out is a one-file change. If those conditions are acceptable, it saves us a few days and a class of production bugs; if not, we write ~200 lines and own it outright.
How can I help you explore Laravel packages today?