APPNETOS is under active development This website and its documentation are being prepared for public launch. Content and features may change.
Select Theme
Loading

Autowire

Registry-backed property dependency injection.

Purpose & processing

Injects the object returned by Core\Registry::get(). If no object is registered, the Registry may create and register it; a missing registration does not imply null.

Parameters

ParameterTypeDefaultBehavior
classstringRequiredFully qualified class name to resolve through the Registry.

Example

#[Autowire(MyService::class)]
protected MyService|null $service = null;

Behavior and considerations

  • The Registry applies its normal class mapping, extension and shared-object rules.
  • An existing non-null property value is preserved.
  • An unresolvable class raises a RegistryException.

Source

shared/src/Core/Annotation/Autowire.php

Next Steps

Previous

Dependency Injection

Explore Dependency Injection

Next

CallObject

Explore CallObject