Symfony 5, Dynamic Database for a specific entity only

I’m working on a Symfony 5 project where every user has its own information in the main database, and they enter their credentials to an external database that will contain the info only for a specific entity "Vehicle". Users can have multiple vehicles, and they can both read and modify their database (the db user will have all privilege).

I looked around for clues on how to do this, but I’m still not sure if I need to change my Vehicle entity, my VehicleRepository repository, create an entity manager every time a user interact with its vehicles, a combination of all of the above, or something else.

More info:

  • There will be no table about vehicles in the main database.
  • All entities other than Vehicle are stored normally in the main database.
  • External databases will have other tables that are not needed by Symfony, but the Vehicle one will always have the same name and structure.
  • If there is something I can do for an extra layer of security with the storage of DB accesses for my users, I’m all ears.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *