Skip to main content
Pagination is route-level. The framework resolves query parameters into a typed Paginator, validates them against the strategy you chose, and emits a standard pagination envelope on the response.

1. Choose a strategy

setMaxLimit() caps what a client can request; the default max is 100. RequestValidationMiddleware rejects limit values above that with 422.

When to pick which

2. Read the paginator in the controller

$request->paginator() returns a PagePaginator, OffsetPaginator, or CursorPaginator depending on the route’s strategy.

Page

Offset

Cursor

3. The JSON envelope

setPaginationResponse() merges a pagination key into the response next to data:
Exact keys depend on the strategy — limit / offset / total for offset, current_cursor / next_cursor / has_more for cursor.

Inside a resource

AbstractListResourceController::pagination() is the hook:
Pair the result with a ResourceListResponse, which takes the PaginationResponseInterface directly in its constructor. See the resource CRUD how-to.

OpenAPI side effects

Apivalk injects the relevant query parameters (page, limit, offset, cursor) into the generated spec, typed and documented, with the setMaxLimit constraint reflected. The response schema gets the correct pagination envelope.

Reference

HTTP / Pagination documents every field of every strategy’s envelope.