DoctrineStaticMeta

Configure Resource Configuration location

docs

Configure Doctrine

Make sure doctrine has been required:

1
composer require doctrine

Add the following to config/packages/doctrine.yaml:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
doctrine:
    orm:
        # ...
        mappings:
            App:
                is_bundle: false
                type: staticphp
                dir: '%kernel.project_dir%/src/Entities'
                prefix: 'App\Entities'
                alias: App

Temporary Measure

For now you need to comment out the naming strategy in config/packages/doctrine.yaml as this causes issues with DSM:

1
2
3
4
5
doctrine:
    orm:
        # ...
#        naming_strategy: doctrine.orm.naming_strategy.underscore
        # ...

Setting Up Dependency Injection

Configure Library Classes

Exclude 'Entities'

You need to make the following change in config/services.yaml:

1
2
3
4
5
services:
    # ...
    App\:
        # ...
        exclude: '../src/{Entities,Entity,Migrations,Tests,Kernel.php}'

Add DSM Library config

You need to add the following to src/Kernel.php:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
    use EdmondsCommerce\DoctrineStaticMeta\Container as DsmContainer;

    // ...

    protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
    {
        // ...

        $this->addDsmServices($container);
    }

    /**
     * @param ContainerBuilder $container
     * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
     */
    protected function addDsmServices(ContainerBuilder $container)
    {
        (new DsmContainer())->addConfiguration($container, $_SERVER);
    }

Configure Savers and Repository Factories

You need to add the following to config/services.yaml:

1
2
3
4
5
6
7
services:
    # ...
    App\Entity\Repositories\:
        resource: '../src/Entity/Repositories/*'

    App\Entity\Savers\:
        resource: '../src/Entity/Savers/*'

Setting Up Validation

TBC