bitrix-service-locator

Installation
SKILL.md

ServiceLocator (DI)

Baseline: main 23.0+ · Verified: main 26.800.0

Where constructor DI is allowed (services yes; controllers via action params; commands and handlers no): bitrix-framework. Domain classes never touch the container.

How get($id) resolves (Since main 26.250*)

Key Result
Built before, or addInstance() the same instance
Not registered, class exists autowired: each ctor param = get(<its type>); a param with a default gets the default
Registered interface / abstract class className → implementation autowired (constructorParams ignored); constructor closure → called with constructorParams as args
Registered concrete class or string id className → new $class(...array_values(constructorParams)), no autowire; constructor closure → called without args
  • Instances are cached for the process unless the entry has 'singleton' => false.
  • A cycle throws CircularDependencyException. An untyped, union or scalar param without a default throws ServiceNotFoundException.
  • Before 26.250: every registered key is built by new $class(...constructorParams) or constructor(). Unregistered classes are autowired only if all ctor params are concrete classes (no interfaces, defaults ignored). No singleton option. On such kernels bind implementations with dependencies through a constructor closure.
Installs
255
GitHub Stars
46
First Seen
Jul 16, 2026