Autoconfigure Doctrine ODM document repositories in Symfony as services to make them injectable into classes without the need to declare them in services.yaml
.
composer require php-arsenal/doctrine-odm-repository-service-compiler-pass
Update your Kernel
class to add this compiler pass.
use PhpArsenal\DoctrineODMRepositoryServiceCompilerPass\DocumentRepositoryAutoconfigureCompilerPass;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
...
protected function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new DocumentRepositoryAutoconfigureCompilerPass());
}
...
}
You can also reach defined document classes through parameter doctrine_mongodb.mongodb.odm.document_classes