Adjusting itemsPerPage and Setting Limits
Adjusting itemsPerPage and Setting Limits
~12 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
The DEFAULT value of 30 can be overridden BOTH by the client PER request AND configured globally PER resource.
Overriding itemsPerPage per request
curl -k 'https://localhost/api/projects?itemsPerPage=10'Returns ONLY 10 instead of 30 projects – the itemsPerPage query parameter ALWAYS works, with NO further configuration needed.
Changing the default page size
#[ApiResource(
paginationItemsPerPage: 10,
normalizationContext: ['groups' => ['project:read']],
denormalizationContext: ['groups' => ['project:write']]
)]
From now on, GET /api/projects returns 10 per page BY DEFAULT instead of 30 – ?itemsPerPage=X STILL works to override this new default when needed.
Setting an upper limit
#[ApiResource(
paginationItemsPerPage: 10,
paginationMaximumItemsPerPage: 50,
// ...
)]
curl -k 'https://localhost/api/projects?itemsPerPage=1000'Achtung: WITHOUT paginationMaximumItemsPerPage, ONE client could request ?itemsPerPage=100000 and thereby UNNECESSARILY strain the database – the upper limit CAPS the value actually applied at the configured maximum, WITHOUT throwing an error.
Disabling pagination entirely
#[ApiResource(
paginationEnabled: false,
// ...
)]
USEFUL for resources with a GUARANTEED small number of entries, like Tag (chapter 12) – there, a fixed, short list WITHOUT pagination overhead is the MORE PRACTICAL choice.
Tipp: ALL three parameters (paginationItemsPerPage, paginationMaximumItemsPerPage, paginationEnabled) can ALSO be set per operation instead of per whole resource – EXACTLY like description in chapter 11.