Editor IDE for custom application components

Hi everyone,

I’m using custom components in my application. So all of them connected in the config under “components”.

However I can’t see any autocomplete for them in my editor, because they added dynamically and never described in any class.

I looked up how it’s done for basic components like “formatter” or “mailer”. They all have comments inside \yii\base\Application.

And after than we have two classes: Yii and \yii\baseYii. The last one (\yii\baseYii) has comment for $app property to connect to \yii\base\Application.

If I change this comment to my own Application class with all comments for new components all is working.

However I use composer, so vendor dir is not under repository control. And when someone clone my repo - he doesn’t have IDE suggestions. And if I setup project again or update Yii - I loose my changes.

Inside main Yii class it is said


/**

 * Yii is a helper class serving common framework functionalities.

 *

 * It extends from [[\yii\BaseYii]] which provides the actual implementation.

 * By writing your own Yii class, you can customize some functionalities of [[\yii\BaseYii]].

 */

So I guess there is a way to write custom Yii class inside my own application. However \Yii point to yiisoft folder and I don’t know how to change this (assuming that I can’t touch vendor folder because it is downloaded with composer)

Can anyone help me with this?

So you don’t intend to customize any functionality in your \Yii class and it’s required only for code completion? In that case there’s no need to actually include it. Just create your own \Yii class and find way to tell your IDE that the new class should be used for code completion.

Of course you can include it if you want. Look for this line in index.php and index-test.php:




require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); //path may be different, depending on application template



and replace the path with one that points to the new \Yii class.

Yeah, All is working fine now, when I created my own Yii.php file and included it in index.php file.

I didn’t notice this include line in index.php file yesterday, so I thought autoload do this kind of magic, that \Yii looks to the vendors folder.

Need more sleep and not working late :)

Anyway, great thanks!