DI container from yiisoft/di should be integrated into main repo replacing old DI classes before 2.1 release.
The location and internal code of the following classes should be rewised:
Keep in mind that namespace yii\di is taken by yiisoft/di package. While Composer allows having multiple folders for the same namespace, I would like to avoid such approach as it will make code navigation difficult.
PR for 'class' keyword fallback should be considered to be handled at yiisoft/yii instead of yiisoft/di. If there will be a graceful way to provide fallback from __class to class it could be done - if not - no fallback will be provided.
I think we can use it via composer instead of getting it into repository directly.
Obviously.
We don't need Instance since there's https://github.com/yiisoft/di/blob/master/src/Reference.php
ServiceLocator could be moved to base.
Another thing is that yiisoft/di doesn't have built-in support for factories (should not be container job, I think) that we use for widgets.
We don't need Instance since there's
Reference
What about Instance::ensure() then? It is widely used around the Yii code.
Yes. That's missing.
Intermediate changeset applied, allowing usage of '__class' keyword for definitions:
b04e0e06dc0939ae0b3c822656f1114f76ee320f
d1ff652b2f0baabbfb9e8776659167508eff5632
Thus the entire code will not break after "yiisoft/di" integration.
I'd suggest to implement __construct() parameter support as well.
yiisoft/diyiisoft/di is a bit raw and not integrated in Yii 2.1, this change will help us to write configs that will work after yiisoft/di adoption.Please, consider reopening: #15815
Will this be PSR-11 compatible?
Yes, yiisoft/di is PSR-11 compatible.
After several attempts to integrate yiisoft/di by me, @SilverFire and @hiqsol which took too much time and weren't really successful decided not to do it. Instead:
yiisoft/yii2. Make it an extension of PSR if possible.yiisoft/di.yiisoft/di.__construct.It's all indicated in roadmap so closing this issue.