E
E
evilelf2016-01-11 14:06:48
Yii
evilelf, 2016-01-11 14:06:48

How to correctly connect your namespace in yii2?

Hello.
There is a need to make a core that inherit from YII2 and that inherit application classes.
How to do it right? So that you can specify use #путь до класса ядра#
And everything worked)
Also, the question is, where is the best place to put the core? To the root?
I use advanced.
The folder will be called core.
Thanks to all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor, 2016-01-11
@evilelf

How to correctly connect your namespace in yii2?

You want to include the class \core\subnamespace\MyClass.
To do this, you must have created a file MyClass.phpalong the path core/subnamespace/MyClass.php.
And then you need to specify in composer.jsonhow to execute herecomposer dumpautoload .
Or add common/config/bootstrap.phpto directory alias
Yii::setAlias('core', dirname(dirname(__DIR__)) . '/core');

And as Alexander wrote N ++ , read about psr-4.

A
Alexander N++, 2016-01-11
@sanchezzzhak

Create folder core in application root
controllers
core
vendor
web
set namespace app\core
use like this use app\core

Also, the question is, where is the best place to put the core? To the root?
I use advanced.

in common if any

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question