2 questions of Yii2 REST

1.Dose Yii2 has a solution for indexAction with filter conditions?

My way is put the conditions into URL like: xxx.com/user?name=jack&age=30, and I write a customized prepareDataProvider function in Controller, in this function I use Yii::$app->request->queryParams to get conditions and generate a ActiveDataProvider then return.

2.Can these options( delete, create and update ) be customized in one Controller file?

As I know, index and view options can be customized in a single the Controller file, but above 3 options can’t. My solution is overriding action() in Controller, such as:

public function actions()


        $actions = parent::actions();

        $actions['create']['class'] = 'app\actions\users\CreateAction';

        return $actions;


the app\actions\users\CreateAction is anther file. how can I define these actions in the same Controller file?


  1. Not out of the box: https://github.com/yiisoft/yii2/issues/4479

  2. Yes. Why not?