Here's a short summary of how the Tempest container works.
Here's an example of a very simple initializer class:
#[Singleton] final readonly class LoggerInitializer implements Initializer { public function initialize(Container $container): LoggerInterface|Logger { return new GenericLogger( $container->get(LogConfig::class), ); } }
A couple of things to note about it:
#[Singleton]
attribute, which means that this dependency will be registered as a
singletonLoggerInterface
or
Logger
is requested from the containerIf you want to know more about initializer discovery in particular, you can check out
\Tempest\Container\InitializerDiscovery