Skip to content

Commit 74ace9a

Browse files
norkunasdunglas
authored andcommitted
Document max items per page setting (#376)
* Document maximum items per page setting * Remove useless method attribute
1 parent a970921 commit 74ace9a

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

core/pagination.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,60 @@ class Book
196196
}
197197
```
198198

199+
## Changing Maximum items per page
200+
201+
### Globally
202+
203+
The number of maximum items per page can be configured for all resources:
204+
205+
```yaml
206+
# app/config/config.yml
207+
api_platform:
208+
collection:
209+
pagination:
210+
maximum_items_per_page: 50
211+
```
212+
213+
### For a Specific Resource
214+
215+
```php
216+
<?php
217+
// src/AppBundle/Entity/Book.php
218+
219+
use ApiPlatform\Core\Annotation\ApiResource;
220+
221+
/**
222+
* @ApiResource(
223+
* attributes={"maximum_items_per_page"=50}
224+
* )
225+
*/
226+
class Book
227+
{
228+
// ...
229+
}
230+
```
231+
232+
### For a Specific Resource Collection Operation
233+
234+
```php
235+
<?php
236+
// src/AppBundle/Entity/Book.php
237+
238+
use ApiPlatform\Core\Annotation\ApiResource;
239+
240+
/**
241+
* @ApiResource(
242+
* collectionOperations={
243+
* "get"={"maximum_items_per_page"=50}
244+
* }
245+
* )
246+
*/
247+
class Book
248+
{
249+
// ...
250+
}
251+
```
252+
199253
## Partial Pagination
200254

201255
When using the default pagination, a `COUNT` query will be issued against the current requested collection. This may have a

0 commit comments

Comments
 (0)