Yii2: How do change Pagination-Per-Page into RESTful Web Service API?

Janka picture Janka · Dec 11, 2014 · Viewed 21.2k times · Source

I am developing an application using AngularJS for the frontend and Yii2 for the backend.

The frontend requires a comprehensive array of all users.

In the documentation of Yii2, http://www.yiiframework.com/doc-2.0/guide-rest-quick-start.html I can read the result divided by X-Pagination-Per-Page: 20

How do I set X-Pagination-Per-Page: ALL ??

Answer

arogachev picture arogachev · Dec 11, 2014

See this example from official documentation.

You can set any necessary number by changing pageSize parameter of pagination:

return new ActiveDataProvider([
    'pagination' => [
        'pageSize' => 10,
    ],
]);

Or you can disable pagination completely and show all available data like this:

return new ActiveDataProvider([
    'pagination' => false,
]);

I don't think this is a right way to pass ALL because it's taken directly from pageSize (which is number).

In case of disabling this header will not be added.