RESTful API Pagination

I made a simple RESTful API following the Yii2.0 guide and it works fine.

My problem is that the response from the API is the pagination of the results. So my MySQL table has 57 entries and when I curl my API it responds with 3 pages because the Pagination-Per-Page is set to 20. How can I get all 57 of the results back on one "page"? Essentially I want all 57 Users returned in one big json string.

My link

set pagination = false.

I figured out the solution, its not very elegant but I think its the proper way to do what I need.

In the UserController class I have to override the index action and prepare the data provider. The Yii2.0 RESTful guide alludes to the solution but does not offer a specific example. So a specific solution to the guide example would be as follows:

public function actions()


    $actions = parent::actions();

    // disable the "delete" and "create" actions

    unset($actions['delete'], $actions['create']);

    // customize the data provider preparation with the "prepareDataProvider()" method

    $actions['index']['prepareDataProvider'] = [$this, 'prepareDataProvider'];

    return $actions;


public function prepareDataProvider()


    return new ActiveDataProvider([

        'query' => User::find(),

        'pagination' => false,



Just posting the solution in case someone else ever needs to something similar.