class ExampleFactory
{
public function __invoke(\Psr\Container\ContainerInterface $container)
{
return new \App\Service\ExampleService(
$container->get(\Laminas\Session\SessionManager::class)
)
}
}
Open the ConfigProvider of the module where your repository resides.
Add a new entry under factories, where the key is your service's FQCN and the value is your factory's FQCN.
See the below example for a better understanding of the file structure.
class ConfigProvider
{
public function __invoke(): array
{
return [
'dependencies' => $this->getDependencies(),
];
}
public function getDependencies(): array
{
return [
'factories' => [
ExampleService::class => ExampleFactory::class,
],
];
}
}
class ExampleService
{
public function __construct(
private \Laminas\Session\SessionManager $session,
) {
}
}