@@ -104,7 +104,60 @@ class TestController extends Controller
104104 {
105105 return $this->json($this->userDao->findAll());
106106 }
107- }```
107+ }
108+ ```
109+
110+ ### Supporting several databases
111+ <small >TDBM 5.2+</small >
112+
113+ It is possible to plug TDBM to several databases.
114+ In this case, you will first want to declare several database connections in DBAL.
115+
116+ For instance:
117+
118+ ** config/packages/doctrine.yaml**
119+ ``` yaml
120+ doctrine :
121+ dbal :
122+ default_connection : default
123+ connections :
124+ default :
125+ # configure these for your database server
126+ url : ' %env(resolve:DATABASE_URL)%'
127+ driver : ' pdo_mysql'
128+ server_version : ' 5.7'
129+ charset : utf8mb4
130+ customer :
131+ # configure these for your database server
132+ url : ' %env(resolve:DATABASE_CUSTOMER_URL)%'
133+ driver : ' pdo_mysql'
134+ server_version : ' 5.7'
135+ charset : utf8mb4
136+ ` ` `
137+
138+ Then, in TDBM, you will use these connections.
139+
140+ **config/packages/tdbm.yaml**
141+ ` ` ` yaml
142+ tdbm :
143+ databases :
144+ default :
145+ bean_namespace : App\Beans
146+ dao_namespace : App\Daos
147+ customer :
148+ connection : doctrine.dbal.customer_connection
149+ bean_namespace : App\Customer\Beans
150+ dao_namespace : App\Customer\Daos
151+ ` ` `
152+
153+ Notice how the "connection" key is pointing to the instance of DBAL connection you are targeting.
154+
155+ Now, when you want to generate beans and Daos, you will have to target the correct database:
156+
157+ ` ` ` bash
158+ $ bin/console tdbm:generate # targets the default database
159+ $ bin/console tdbm:generate:customer # targets the "customer" database
160+ ```
108161
109162Next step
110163---------
0 commit comments