Symfony 4-不要在生产中加载DataFixtures

时间:2018-06-22 15:59:40

标签: php symfony symfony4

在生产中,不存在DoctrineFixturesBundle,因此当Symfony尝试注册我的DataFixtures类时,将引发错误。

这是我尝试过的方法,但似乎Symfony忽略了services_prod.yaml,或者它没有正确覆盖配置。

config / services.yaml

services:
    App\:
        resource: '../src/*'
        exclude: '../src/{Entity,Exception,Migrations,Test,Tests,Kernel.php}'

config / services_prod.yaml

services:
    # Override default to exclude DataFixtures
    App\:
        resource: '../src/*'
        exclude: '../src/{DataFixtures,Entity,Exception,Migrations,Test,Tests,Kernel.php}'

关于如何让Symfony不将DataFixtures类注册为生产中的服务的任何想法吗?

1 个答案:

答案 0 :(得分:1)

确保两个环境中都允许捆绑销售,请参阅config / bundles.php

Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true]

Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'prod' => true]