Multiple database connections on Yii3

Hi everyone,

I’m currently working with Yii3 and I’m trying to understand the best way to handle multiple database connections.

In Yii2 this was quite straightforward and well-documented, but in Yii3 I’m honestly struggling to find a clear and practical approach. The documentation and examples I’ve found so far are a bit confusing, and I’m not sure what the recommended pattern is.

My use case is simple: I need to work with more than one database connection within the same application (e.g., different tenants or separate data sources).

So my questions are:

  • Is there an official or recommended way to configure and manage multiple DB connections in Yii3?
  • Are there any examples or best practices available?
  • How should this be integrated with repositories / Active Record (if applicable)?

Any guidance, examples, or pointers to documentation would be greatly appreciated.

Thanks in advance!