Services (PHP library)

Services is a PHP library that provides a generic service container to manage named services using lazy instantiation based on instantiator callback functions. It powers MediaWiki's dependency injection through. The library is also compatible with the PSR-11 Container Interface.

Usage
Where ServiceWiring.php looks like this:

Each instantiator receives the service container as the first argument, from which it may retrieve further services as needed. Additional arguments for each instantiator may be specified when constructing the. Custom subclasses of  may offer easier access to certain services: