如果要防止数据库夹具意外加载在错误的环境中,(可能)最好的方法是只在特定环境中激活DoctrineFixturesBundle。
直到Symfony 3.4,这是在app/AppKernel.php中完成的,正如practices/business-logic.html#data-fixtures中所描述的那样
如何在Symfony 4 (Symfony Flex)中实现这一点,其中的捆绑包是自动加载的?
发布于 2018-06-10 20:43:00
在Symfony 4中,可以通过编辑行在config/bundles.php中配置
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],请参阅practices/business-logic.html#data-fixtures
当您移除'dev' => true,部件,然后尝试通过运行php bin/console doctrine:fixtures:load --env=dev加载DEV环境中的夹具时,您将得到:
运行命令时抛出的错误“原则:安装:load‘--env=dev”。消息:“在”原则:固定装置“命名空间中没有定义任何命令。
但是,在测试环境中加载它们仍然有效:php bin/console doctrine:fixtures:load --env=test
https://stackoverflow.com/questions/50787871
复制相似问题