From magento2-commerce
Configures Magento 2 dependency injection via di.xml: types, virtual types, preferences, argument replacement, Object Manager. Use for wiring dependencies, class variations, module integrations.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin magento2-commerceThis skill is limited to using the following tools:
**Fetch live docs**:
Generates design tokens/docs from CSS/Tailwind/styled-components codebases, audits visual consistency across 10 dimensions, detects AI slop in UI.
Records polished WebM UI demo videos of web apps using Playwright with cursor overlay, natural pacing, and three-phase scripting. Activates for demo, walkthrough, screen recording, or tutorial requests.
Delivers idiomatic Kotlin patterns for null safety, immutability, sealed classes, coroutines, Flows, extensions, DSL builders, and Gradle DSL. Use when writing, reviewing, refactoring, or designing Kotlin code.
Fetch live docs:
site:developer.adobe.com commerce php development components dependency-injection for the DI guidehttps://developer.adobe.com/commerce/php/development/ and navigate to DI documentationsite:developer.adobe.com commerce php development build di-xml for di.xml referenceMagento's Object Manager reads di.xml configurations and automatically injects dependencies into class constructors. You declare what you need; the framework provides it.
Constructor injection is the primary pattern — declare dependencies as constructor parameters with type hints.
di.xml files are area-scoped:
etc/di.xml — global (all areas)etc/frontend/di.xml — storefront onlyetc/adminhtml/di.xml — admin panel onlyetc/webapi_rest/di.xml — REST API onlyetc/webapi_soap/di.xml — SOAP API onlyConfigure constructor arguments for a specific class:
string, boolean, number, const, null, object, array, init_parameterCreate class variations without writing new PHP files:
type attribute value)Map an interface to a concrete implementation:
<preference for="InterfaceName" type="ConcreteClassName" />| Type | Description |
|---|---|
string | String value |
boolean | true or false |
number | Integer or float |
const | PHP constant value |
null | Null value |
object | Another class instance (injected) |
array | Array of mixed argument types |
init_parameter | Value from Magento\Framework\App\DeploymentConfig |
shared="false" on a type to get a new instance each timeSomeClassFactory) always create new instancesinit_parameter type reads from app/etc/env.php — use for environment-specific values that shouldn't be in di.xml.
shared="false" sparingly — most dependencies should be sharedFetch the DI documentation for exact XML schema, element attributes, and current best practices before configuring.