Answer the question
In order to leave comments, you need to log in
How to correctly set up routing for a nested module in Yii2?
I'm making a versioned REST ful API. The structure is:
Modules:
- api:
--- controllers
--------- BookController
--- models
--- Module.php
--- modules:
--------- controllers
--- ----------- BookController
--------- models
--------- Module.php
BookController:
class BookController extends ActiveController {
public $modelClass = 'app\modules\api\models\Book';
}
'modules' => [
'api' => [ 'class' => 'app\modules\api\Module', ],
'v1' => [ 'class' => 'app\modules\api\modules\v1\Module', ],
],
'components' => [
'request' => [ 'parsers' => [ 'application/json' => 'yii\web\JsonParser' ],
'baseUrl' => ''
'urlManager' => [
'rules' => [
'' => 'site/index',
['class' => 'yii\rest\UrlRule', 'controller' => 'api/book'],
['class' => 'yii\rest\UrlRule', 'controller' => 'api/v1/book'],
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question