问题
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
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 ?
回答1:
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.
回答2:
you can define a symfony service for each of your entitymanagers and inject the desired one explicitly into your fixture class afterwards. the fixture would then be a service as well.
来源:https://stackoverflow.com/questions/56419241/how-to-specify-a-database-connection-to-doctrine-fixtures