Assign DefaultRoute Module Yii2

Hello good afternoon I have a module in yii2, and I have tried to change the defaultRoute in:

Module.php:


class Module extends BaseModule

{

    const VERSION = '0.0.1-dev';


    public $defaultRoute = 'pages';


    public function init ()

    {

        parent :: init ();

    }

}



But it does not work, any suggestions.

Please show full code of Module

defaultRoute will be changed in file config/web.php, not in module class. You can add something like this to this file :




$config = [

   ...,

   'modules' => [

        'module_name' => [

            'class' => 'app\modules\module_name\Module',

        ],

   ],

  'defaultRoute' => 'module_name/controller_name/action_name',