S
S
Sergey Melnikov2016-01-14 13:02:08
Yii
Sergey Melnikov, 2016-01-14 13:02:08

Why doesn't app space work in common yii2 folder?

There is a model in which the namespace is app\models, the model is in common\models
When accessing the model from the code that is in the frontend, I write use app\models\...
It gives an error, I can’t find the model. I transfer the model file to the frontend \ models folder, everything starts working. Tell me why?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Khomenko, 2016-01-14
@iiifx

There is PSR-4, autoload rules follow it, it all works through Composer. You have a second Yii, right?
The model in the common\models folder must have the common\models namespace.
Do you have some hybrid of basic and advanced versions of Yii2? Where did the app namespace come from in the common folder?

M
Mikhail Artemiev, 2016-01-14
@the_mix

Because there are only two apps (applications) in the advanced template, these are backend and frontend , and the " app " alias is equal to the namespace of the application inside which it is specified, and it does not work outside the folders of these applications, and cannot work, because it does not make sense.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question