如何指定到Doctrine装置的数据库连接? [英] How to specify a database connection to Doctrine fixtures?

查看:71
本文介绍了如何指定到Doctrine装置的数据库连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Symfony 4 ,并且有一个 CI管道可以将我的应用程序部署到开发服务器。使用 Doctrine 功能,我可以使用-db-configuration 选项执行数据库迁移:

I am using Symfony 4 and I have a CI pipeline to deploy my app to a dev server. Using Doctrine features, I can execute the database migrations using a --db-configuration option:

./bin/console doctrine:migrations:migrate \
    --allow-no-migration \
    --db-configuration=dev_conn.php \
    --no-interaction

我会想要以相同的方式加载灯具,但是 doctrine:fixtures:load的帮助中未列出-db-configuration 选项命令。

I would like to load the fixtures in the same manner, but the --db-configuration option isn't listed in help for the doctrine:fixtures:load command.


  • 此命令是否有隐藏 选项,这样做吗?

  • 如果没有,那么能够在我的远程服务器上加载固定装置的最佳解决方法是什么?

  • Is there an "hidden" option to this command which could do this ?
  • If not, what would be the best workaround to be able to load fixtures on my remote server ?

推荐答案

使用远程服务器的凭据(使用另一个环境变量)创建另一个实体管理器,如在文档中找到ultiple_entity_managers.html rel = nofollow noreferrer> ,然后在夹具命令中传递选项 —em = your_second_manager

Create another Entity Manager with credentials of the remote server (using another environment variable) as described in the documentation and pass the option—em=your_second_manager in your fixtures command.

这篇关于如何指定到Doctrine装置的数据库连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆