Есть такая структура для basic
modules/api/v1/controllers/PersController.php
<?php
namespace api\modules\v1\controllers;
use app\models\Pers;
use yii\rest\ActiveController;
class PersController extends ActiveController
{
public $modelClass = Pers::class;
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['corsFilter' ] = [
'class' => \yii\filters\Cors::className(),
];
return $behaviors;
}
}
config/web.php
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
'enableStrictParsing' => true,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
// 'signup' => '/myshop/default/signup',
// 'submitsignup' => '/myshop/submitsignup',
['class' => 'yii\rest\UrlRule', 'controller' => 'api/v1/pers'],
),
],
'request' => [
'enableCookieValidation' => true,
'enableCsrfValidation' => true,
'cookieValidationKey' => '-Ghw8jpJL-0okgil5QLXZdNW2tHJIiBT',
'parsers' => [
'application/json' => 'yii\web\JsonParser',
]
],
],
'modules' => [
'admin' => [
'class' => 'app\modules\admin\Module',
],
'user' => [
'class' => 'amnah\yii2\user\Module',
],
'api' => [
'class' => 'app\modules\api\v1\Module',
],
],
но