This question has already been answered:
Symfony 3. The project uses the main database. There is a task: to take data from the main database, process it and put it in several other databases. How to configure the application so that you can quickly switch between different databases?