php-arsenal/doctrine-odm-repository-service-compiler-pass

Autoconfigure Doctrine ODM document repositories in Symfony as services.

0.2.1 2021-11-03 12:25 UTC

This package is auto-updated.

Last update: 2024-10-29 06:12:43 UTC


README

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

Release CI Packagist

How to use?

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