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.


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. – Suresh Chikani Jul 29 '16 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy