K
K
Krivetka812019-04-03 17:05:42
Yii
Krivetka81, 2019-04-03 17:05:42

Why don't my actions work in yii2 rest?

Their actions do not work, "Not Found (#404)" is returned, while the standard ones from ActiveController work
Settings urlManager

'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'showScriptName' => false,
            'rules' => [
                [
                    'class' => 'yii\rest\UrlRule',
                    'controller' => ['user', 'order', 'product'],
                    'pluralize' => false,
                ],
            ],
        ],

The class where the action is written
class ProductController extends BaseApiController
{
    public $modelClass = 'frontend\models\rest\Product';

    public function actionSome(){
        return ['some text'];
    }
}

BaseApiController inherits from ActiveController

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question