What does Magento mean by Dependency Injection, and why is it different from "just use new"?

Magento's DI container is in Magento\Framework\ObjectManager. You never call new Vendor\Module\Foo() in production code, you type-hint the dependency in your constructor and the container auto-wires it, applying any preference, plugin chain, or virtualType from etc/di.xml. This is what lets a third-party module plug your service without changing your code. Two flavours: Constructor Injection (preferred, type-hinted, eager) and Method Injection via ObjectManager::create() (only legal in factories, repositories, and setup scripts). Calling ObjectManager::getInstance() in a controller is the Magento equivalent of a code smell, reviewers will fail the PR.

Kishan Savaliya
Kishan Savaliya
Adobe Certified Magento Commerce Developer
Ahmedabad [IN]working hours, replies within four hours
When do you need it

Read personally. Never shared. Or email the brief.

More on claude, glossary

Need it fixed, not just explained?

Send the brief with your store URL; the written quote comes back within 24 hours.