T
T
Tokenchik2017-04-11 14:10:59
Yii
Tokenchik, 2017-04-11 14:10:59

How to solve View not Found - yii\base\ViewNotFoundException?

Transferred the site to yii to the hosting, everything works except the admin module, I felt great on openserver, everything worked, after the transfer to the hosting the module stopped working, an error is displayed:

View not Found - yii\base\ViewNotFoundException
The view file does not exist: / home/electro1/public_html/site.ru/modules/admin/views/order/index.php

bd77e2f3ab294e79953cca8ae0aabe98.JPG

042362363000414fb4bf4bd214447115.JPG

On the second screen, line 51 is highlighted in red, I could not fix it yet. The php requirements version does not swear.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
Maxim Fedorov, 2017-04-11
@Tokenchik

Is the file itself?
Most likely you have a problem with file permissions, trust them

M
Maxim Timofeev, 2017-04-11
@webinar

Judging by

/home/electro1/public_html/site.ru/modules/admin/views/order/index.php

and specifically on
site.ru
you have a beard in your config. Somewhere the domain is registered and not correct.

M
Mi7teR, 2017-04-11
@Mi7teR

the controller complains about the missing view index.php file. Check for the existence of a file by path

/home/electro1/public_html/site.ru/modules/admin/views/order/index.php

A
Alli_baba01, 2019-04-07
@Alli_baba01

the same problem occurs when I re-create models with Gii.

I
Igor Vasiliev, 2019-07-09
@Isolution666

Write a function.

...
use yii\base\ViewNotFoundException;
...
$path = Yii::getAlias('@web').'/order/index';
...
try {
    // 1) тут пишите то что хотите проверить
    $this->render($path, ['dataProvider' => $dataProvider]);
} catch (ViewNotFoundException $e) {
    // 2) тут выводите "удобную" ошибку, чтобы не закрывать ошибкой 500 или той которая вылезает
    $this->render('myerror');
}
...

You can also contact Yii::getAlias('@frontend')- what if the project is not in the folder frontend???
So no return ...;Either you get the view or myerror
the ViewNotFoundException keeps track of it.
Yes, if there is a file, no errors will come out, and if there is no file, you will encounter ViewNotFoundException
So why not immediately catch the error and just display it as text on the page?
Much better than a full page error.
Well, is it Easy? Truth? :)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question