New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yii 2.0 will be with dependency injection? #814
Comments
No, we support a feature not because other frameworks support it, but because we need it in real life. |
Please use http://www.yiiframework.com/forum/index.php/forum/42-design-discussions-for-yii-20/ for design discussions about Yii2. |
Is there any reason why you would think Dependency Injection is not something that's used in real life? In my experiences, it's crucial to create testable and self-contained classes, and ease the process of mocking dependencies for classes. |
@soggie even 1.1 has DI. Yii is a practical framework, not something you use because it has all these fancy patterns and stuff. We're just not emphasizing on patterns, that's it. |
@soggie, and yes, Yii's approach isn't less testable and less maintainable. Take a look at the existing unit tests of the framework if you want real examples of replacing components in the testing environment. |
Well, not trying to start any arguments here. I use DI myself, and feel that it's a wonderful pattern with plenty of real world applications (in fact, our current production system uses a somewhat homemade DI container), so I was wondering as to why you would think DI is not something anybody needs in real life. Just hoping for a more detailed explanation as to the design decision not to include DI, that's all. :) I haven't gone through the code of Yii, and I'll probably take a deeper dive tonight. |
@soggie DI is a good pattern and DI is there in Yii 1.1. Besides that many classical patterns are used in Yii we don't think it worth emphasizing it like "here we're using DI and here we're using a factory and there's the registry". |
@samdark I'm totally agree with you, but why not emphasizing at least for avoid some excess questions and from political point of view? |
Because it complicates things for newbies a lot. When emphasizing on patterns you're actually emphasizing on "how" instead of "what". |
@samdark, agreed it's excessive for newbies, but it would be nice to have one or more articles that cover some of the more prominent features of Yii, including the [anti-]patterns used (and why?, such as what advantages the approach provides), along with links to more advanced reading (such as Martin Fowler's explanation of DI). I've worked fairly extensively with Yii 1.1 for various projects, and mimicked & used the patterns I've found in Yii within my own code, but I didn't know until tonight that one such pattern was Dependency Injection. So that means while I've had practical knowledge regarding the implementation & usage, I would've had no clue what was being referred to (without a notable explanation) if a colleague were to bring up Dependency Injection or Inversion of Control. So at least having an area to further educate on such patterns (or at least reference explanatory links) would be quite helpful for other Yii developers. |
Yep, maybe a set of wiki articles will be suitable for it. Will consider writing some later. |
The only features Qiang uses are the ones he can teach other to :) |
@creocoder Would you like |
I'm strongly against it. |
@cebe Ofcourse not. I mean another things, mostly docs ;) |
I found this thread while searching how to use DI in Yii controller. Here is my post on the forum, so if anyone can answer it, it will be great: http://www.yiiframework.com/forum/index.php/topic/52810-using-interfaces-and-di-in-yii-controllers/ |
I think, Yii have IoC only on Application Object, used to manage component. |
yii 2 has DI container: http://www.yiiframework.com/doc-2.0/guide-concept-di-container.html |
wow, great news for me, thanks @cebe |
Like We have seen other frameworks are coming with 'dependency injection' feature. so in Yii 2.0 we should have ,.,
The text was updated successfully, but these errors were encountered: