Skip to content

DoctrineStaticMeta

Configure Resource Configuration location

docs

Configure Doctrine

Make sure doctrine has been required:

composer require doctrine

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

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:

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:

services:
    # ...
    App\:
        # ...
        exclude: '../src/{Entities,Entity,Migrations,Tests,Kernel.php}'

Add DSM Library config

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

    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:

services:
    # ...
    App\Entity\Repositories\:
        resource: '../src/Entity/Repositories/*'

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

Setting Up Validation

TBC