Does it hurt to have a lot of auto import directories as defined in the 'import' configuration? Will this slow the app down? I feel like it might, but I would like some advice.
Because I have some controllers set to auto-import on demand (because I have some other controllers that inherit from the auto-load controllers), I am wondering if it is better just to import() them
I don't know because I haven't try to auto import with many component. But I think it will not effect all application performance. Just will effect on event importing component or a class because Yii use a lazy loading method to load resource just when it will use. Yii will not load all component even if you auto load many component on your configuration.
Do not import too many directories because it relies on PHP include_path. If you have a long PHP include_path, the performance may be degraded when including a file without absolute path.
I see you can make path aliases with YiiBase::setPathOfAlias(), but wouldn't it be nice to set path aliases in your config file? For instance right now I have this in the config:
I see you can make path aliases with YiiBase::setPathOfAlias(), but wouldn't it be nice to set path aliases in your config file? For instance right now I have this in the config:
Now I don't have the negative effects of a long include_path, and I can call a widget like this:
<?php $this->widget('widgets.MyWidget'); ?>
Jonah, I just had a thought. Your approach, as Qiang said, would require syntax dissemination and be a fundamental shift in the way aliases are utilized in Yii.
I don't think that's a good thing.
However… a NEW section within the config file. This would be a decent approach as only people who need it can use it, it is a new feature, and can easily be implemented.
For example, we can add a new section called 'importAliases'. In this array are your mappings. Next, add a method to YiiBase(::importAliases) which will read the array and do the mappings.