Amir Amir - 4 months ago 13
PHP Question

What's the difference between "app" and "backend" in yii

what's the difference between these two lines of codes? do they refer to a same place?

use app\models\EntryForm;
use backend\models\EntryForm;


I'm using the advanced yii2

and in the yii tutorial it just uses
app
and I think that's because it's talking about the basic yii version. but as I said what are the differences? should I only use
backend
while using the advanced version and
app
is not allowed?

Answer

the names app or backend or frontend are names of an application ..

if you are using advanced template .. you should refer to the related application using for backend

use backend\models\EntryForm; 

and the namespace definition you should use eg:

namespace backend\models\;  

or for frontend

use frontend\models\EntryForm; 

namespace frontend\models\;  

for common part you can use

   common\models

   use common\models\EntryForm;

The structure is related to the https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md