Yii Basic Problem/question

Hello,

I used the basic template to create my first YII Application.

This works fine so far…

But no I created a new controller, but I can’t access it :(

The Controller is called "ServiceController" and has a "actionIndex" function.

But when I now try to call my new controller like this:

http://local.dev/index.php?r=service

I get this error:

When I call: "http://local.dev/index.php?r=site" everything works fine.

What do I need to configure to call my new controller?

And one more question:

Where is the config, that says, when simply calling the index.php, that the index action of the site controller is called?

Thank,

Urkman

Make sure your controller extends from yii\web\Controller and not yii\console\Controller !

For the controller it is defaultRoute in application config:

http://www.yiiframework.com/doc-2.0/yii-web-application.html#$defaultRoute-detail

for the index action it is defaultAction property of controller:

http://www.yiiframework.com/doc-2.0/yii-base-controller.html#$defaultAction-detail

Hello,

That exactly was my problem… I had this in my file:


use yii\console\Controller;

and not this:


use yii\web\Controller;

OK, ‘site’ is the default value… And I was looking all over my code to find a setting for that…

Thanks,

Urkman