class ExampleConfig {
#[ServiceDefinition]
public function innerService1(): SimpleService {
return new SimpleService('Hello');
}
#[ServiceDefinition]
public function innerService2(): SimpleService {
return new SimpleService('world!');
}
#[ServiceDefinition(isPublic: true)]
public function combinedService(SimpleService $innerService1, SimpleService $innerService2): CombinedService {
return new CombinedService($innerService1, $innerService2);
}
}
protected function configureContainer(ContainerBuilder $container, Loader $loader): void {
$loader->getResolver()->addLoader(new Kostislav\ClassConfig\ConfigClassServiceConfigLoader($container));
// other stuff
}
protected function configureContainer(ContainerBuilder $container, Loader $loader): void {
$loader->getResolver()->addLoader(new Kostislav\ClassConfig\ConfigClassServiceConfigLoader($container));
// now you can load all your config classes with $loader
$loader->load(MyConfig::class);
}
#[ServiceDefinition('alternative.name')]
public function whatever(): SimpleService {
return new SimpleService('serv1');
}
#[ServiceDefinition(isPublic: true)]
public function publicService(): SimpleService {
return new SimpleService('serv1');
}
#[ServiceDefinition]
public function myService(#[Service('annotations.cached_reader')] Reader annotationReader): SimpleService {
// do whatever here
}
#[ServiceDefinition]
public function myService(#[Parameter('kernel.debug')] string $debug): SimpleService {
// do whatever here
}
#[Import(AnotherConfig::class)]
class OneConfig {
// some service definitions here
}
#[Tag('kernel.event_listener')]
#[ServiceDefinition]
public function myService(): SimpleService {
// do whatever here
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.