Core

Autowiring

Reflection-based constructor autowiring fallback and when explicit binding is required.

Autowire rules

Autowiring fallback works for instantiable classes with class-typed constructor dependencies. Interfaces must have explicit container binding (isBound check). Builtin/scalar params must have defaults or be handled by explicit factory binding.

Typical failure

When interface dependency is not bound, container throws ServiceNotFoundException.

if (interface_exists($dependency) && !$this->isBound($dependency)) {
    throw new ServiceNotFoundException(
        sprintf('Cannot autowire "%s::$%s". Interface "%s" has no container binding.', $className, $parameterName, $dependency)
    );
}