Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Dependency Injection and Mixins the same thing?

I am trying to get accustomed to the ways of PHP 5.3 and I am confused. :o

Are they both accomplishing the same thing?

like image 584
johnjohn Avatar asked Oct 26 '25 08:10

johnjohn


1 Answers

No, they are very different. Dependency injection means "give me all of the objects I need to do my task." A good counter-example would be a class that uses other singleton classes or has other hard-coded dependencies.

Mixins are essentially objects or classes that you can more or less merge with an existing object or class to provide its behavior to the consumer of that object.

like image 177
cdhowie Avatar answered Oct 28 '25 23:10

cdhowie