Custom action data provider

    public function actions()

        $actions = parent::actions();

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

        $actions['index']['prepareDataProvider'] = [$this, 'prepareDataProvider'];
//        echo "<pre>";
//        var_dump('aaaaaaaa');
//        echo "</pre>";
//        die;
        return $actions;

public function prepareDataProvider()
    $query = FavoriteBook::find()
    ->andWhere(['user_id' => Yii::$app->user->id]);

    return new ActiveDataProvider([
        'query' => $query,
        'pagination' => [
            'pageSize' => Yii::$app->request->get('per-page', 10),
        'sort' => [
            'params' => Yii::$app->request->get(),

When Accessing my local server: http://ecommerce-book-backend.test/favorite-book
I got Object configuration must be an array containing a “class” or “__class” element.
I followed the documentation in that phase what am I doing wrong that is causing that?

It would be more useful to see the entire stack trace in order to help you.

Check the API referrence of yii\web\Controller::actions().

But you are returning an array with an unexpected format:

Check also “Standalone Action” in the following section of the guide: