Я зарегистрировал модуль в web.php:
Код: Выделить всё
'bootstrap' => [ 'log', 'v1', 'v2'],
'modules' => [
'v1' => [
'class' => api\modules\v1\ApiV1Module::class,
'controllerNamespace' => 'api\modules\v1\controllers',
],
'v2' => [
'class' => api\modules\v2\ApiV2Module::class,
'controllerNamespace' => 'api\modules\v2\controllers',
],
],
Код: Выделить всё
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
Код: Выделить всё
public function bootstrap($app)
{
\Yii::info("ApiV2Module is bootstrapping", __METHOD__);
\Yii::info("Incoming request to: " . \Yii::$app->request->url, __METHOD__);
$app->getUrlManager()->addRules([
'/v2/user/' => '/v2/user/index',
'/v2/friends/' => '/v2/friends/index',
'/v2/challenge/' => '/v2/challenge/index',
'/v2/challenge//' => '/v2/challenge/',
'/v2/exercises/' => '/v2/exercises/index',
'/v2/exercises//' => '/v2/exercises/',
'/v2/notifications/
' => '/v2/notifications/index',
'/v2/notifications/' => '/v2/notifications/',
'/v2/user/goals/' => '/v2/user/goals',
'/v2/user/exp/' => '/v2/user/exp',
]);
}
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/79036277/yii2-module-loading-but-404-with-every-route-in-this-module[/url]