I started to use Magento 2.x and noticed that the Mage "API" is no longer a reality, and red about dependency injection and factory but I did not understand what it is, what it does or where I write its code (path).

Can anyone help?

Thanks in advance.

1 Answer 1


By default, the object instance is shared. If you request the same object many times in different classes you will get the same instance.

magento 2: understanding dependency injection

Factory Class vs. Proxy Class in magento2

You can read from here magento officially site.

Read more about Factories


Read more about Dependecy injection


  • You have to add code in module block. Jul 29, 2016 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.