Yii2: Omit controller ID from module route -


a typical yii2 route action in module controller follows:

<moduleid>/<controllerid>/<actionid>

how configure/structure our module (which has 1 controller) may reach actions directly using following route:

<moduleid>/<actionid>

without having override routes in main application's urlmanager?

if "without having override routes in main application's urlmanager" mean not modifying urlmanager routes think it's not possible.

but if mean "without new route rules added in app's configuration file" here way:

you can setting rules inside module.

add module bootstrap section of configuration if it's not there yet.

now in main module's file (default module.php) add:

public function bootstrap($app) {     if ($app instanceof \yii\web\application) {         $app->urlmanager->addrules([             ['your-module/<action>' => 'your-module/controllers-name/<action>'],         ]);     } } 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -