Documentation Index
Fetch the complete documentation index at: https://docs.apivalk.com/llms.txt
Use this file to discover all available pages before exploring further.
Route Configuration
To enable pagination for a specific route, you use thepagination() method on the Route object. This automatically handles the documentation and request parameter resolution (like page, limit, offset, or cursor).
Supported Types
Pagination::page(): Standard page-based pagination (usespageandlimit).Pagination::offset(): Offset-based pagination (usesoffsetandlimit).Pagination::cursor(): Cursor-based pagination (usescursorandlimit).
Usage in Controller
When a route has pagination enabled, theAbstractApivalkRequest automatically creates the appropriate paginator object. You can access it via the paginator() method.
1. Fetching Data
Use thePaginatorFactory to resolve the paginator from the request and apply it to your repository or data source.
2. Attaching Metadata to Response
After fetching your data, you must create aPaginationResponse object and attach it to your response. This ensures the pagination metadata (like total_pages or has_more) is included in the JSON output.
JSON Output Example
When a response has a pagination object attached, theJsonRenderer automatically includes a pagination key in the response body. The structure depends on the pagination type used.