Getting controllerMap to work

Hi,

I am having my first play around with Yii2 and working my way through the Yii2 Documentation Definitive Guide and am trying to get the controllerMap configuration setting to work.

My config/web.php looks like this:





<?php


$params = require(__DIR__ . '/params.php');


$config = [

    'id' => 'basic',

    'basePath' => dirname(__DIR__),

    'bootstrap' => ['log'],

    'components' => [

        'request' => [

            ...

        ],

        'cache' => [

            ...

        ],

        'user' => [

            ...

        ],

        'errorHandler' => [

            ...

        ],

        'mailer' => [

            ...

        ],

        'log' => [

            ...

        ],

        'db' => require(__DIR__ . '/db.php'),

    ],

    'controllerMap' => [

	[

		'random' => [

			'class' => 'app\controllers\CountryController',

		],		

	],

    ],

    'params' => $params,

];


if (YII_ENV_DEV) {

    ....

}


return $config;




My understanding is that the following URL:

http://localhost-yii.dev/index.php?r=random

should redirect to the country controller, effectively being the same as URL

http://localhost-yii.dev/index.php?r=country

But all am I getting is a 404 Not found page

Please let me know if there is anything I am missing or if I have misunderstood the role of the controllerMap

Do you have debugging enabled? I highly recommend that

Other thing I can think of is - is there a namespacing issue with your target controller? (debugging will help you locate this)