Unable to resolve the request 'site/error'

I’m trying out the yii2 framework, and when I’m trying to access frontend/web/index.php, I get the following error:

An Error occurred while handling another error: yii\base\InvalidRouteException: Unable to resolve the request “site/error”. in C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\base\Module.php:537

Stack trace:
#0 C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\web\ErrorHandler.php(108): yii\base\Module->runAction(‘site/error’)
#1 C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\base\ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\web\NotFoundHttpException))
#2 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\web\NotFoundHttpException))
#3 {main}

Previous exception: yii\base\InvalidRouteException:
Unable to resolve the request “”. in C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\base\Module.php:537
Stack trace: #0 C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction(’’, Array)
#1 C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 C:\xampp\htdocs\fsayii2\frontend\web\index.php(17): yii\base\Application->run()
#3 {main}

Next yii\web\NotFoundHttpException: Page not found. in C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\web\Application.php:115 Stack trace:
#0 C:\xampp\htdocs\fsayii2\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 C:\xampp\htdocs\fsayii2\frontend\web\index.php(17): yii\base\Application->run()
#2 {main}

I’m confused and don’t know what went wrong. Everything was working fine until I tried requesting a session, and then the error above showed up. I deleted my session code, but it still doesn’t work…I would paste some code here but I don’t know what to paste.

More details:
I can’t access anything in frontend/web/index.php?r=site/pagename.
The page error.php exists and I haven’t changed any of the code there yet. I haven’t touched SiteController.php either.
I checked all the previous topics in the forum on this error and none of them seem to be the same situation I’m in.

Thanks in advance!

Hi there, it seems like there’s a problem with your routes definitions / resolving.

Is your SiteController still present under frontend/controllers/ ?

It looks like I somehow accidentally moved the controllers folder out of frontend; I hadn’t thought to check that. It works now. Thanks so much!

A little tip here: you can do git init and commit your changes locally from time to time. When you’re lost, git status will show you what happened to your files :slight_smile:

Maybe you should set Yii::setAlias('@frontend', dirname(dirname(__DIR__)) . '/frontend'); in common/config/bootstrap.php

1 Like

Boa tarde. Sou novo aqui. Tenho uma pasta controllers em meu projeto. Tenho q fazer uma copia dela para esta pasta?
Obrigado.

Hi @LCamilosr, welcome to the forum.

Please use English here in the “General Discussions” sub forum, or we’ll have difficulty in communicating each other.

My setup is apparently strange.

There’s no frontend folder. Maybe it was changed?

I’m unclear on which bootstrap file I should be targeting.

Please open new threa and make sure you explain your problem