R
R
rusline2017-02-11 13:57:24
Yii
rusline, 2017-02-11 13:57:24

I don't understand the namespace in yii2?

My main index.php works, which binds main.php, but for some reason if I create a new page for the site and connect appAsset, then I get an error

Fatal error: Class 'frontend\assets\AppAsset' not found in C:\OpenServer\ultimat\OpenServer\domains\pergrowth\frontend\web\feedback.php on line 13

Where should I look for path change or in index.php connect to this file? I just don't understand how it works
Or the second question is how to create pages with steels?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-02-11
@slo_nik

Good afternoon.
Include in the main template, that is, in views/layouts/main.php
If you include in another file, you must first specify the location of the file with the class, and then call the methods of this class.
Wrong:
Right:

use app\assets\AppAsset;

AppAsset::register($this);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question