@@ -128,57 +128,47 @@ The following configuration code shows how you can configure two entity managers
128128 .. code-block :: php
129129
130130 // config/packages/doctrine.php
131- $container->loadFromExtension('doctrine', [
132- 'dbal' => [
133- 'default_connection' => 'default',
134- 'connections' => [
135- // configure these for your database server
136- 'default' => [
137- 'url' => '%env(resolve:DATABASE_URL)%',
138- 'driver' => 'pdo_mysql',
139- 'server_version' => '5.7',
140- 'charset' => 'utf8mb4',
141- ],
142- // configure these for your database server
143- 'customer' => [
144- 'url' => '%env(resolve:DATABASE_CUSTOMER_URL)%',
145- 'driver' => 'pdo_mysql',
146- 'server_version' => '5.7',
147- 'charset' => 'utf8mb4',
148- ],
149- ],
150- ],
151-
152- 'orm' => [
153- 'default_entity_manager' => 'default',
154- 'entity_managers' => [
155- 'default' => [
156- 'connection' => 'default',
157- 'mappings' => [
158- 'Main' => [
159- 'is_bundle' => false,
160- 'type' => 'annotation',
161- 'dir' => '%kernel.project_dir%/src/Entity/Main',
162- 'prefix' => 'App\Entity\Main',
163- 'alias' => 'Main',
164- ]
165- ],
166- ],
167- 'customer' => [
168- 'connection' => 'customer',
169- 'mappings' => [
170- 'Customer' => [
171- 'is_bundle' => false,
172- 'type' => 'annotation',
173- 'dir' => '%kernel.project_dir%/src/Entity/Customer',
174- 'prefix' => 'App\Entity\Customer',
175- 'alias' => 'Customer',
176- ]
177- ],
178- ],
179- ],
180- ],
181- ]);
131+ use Symfony\Config\DoctrineConfig;
132+
133+ return static function (DoctrineConfig $doctrine) {
134+ $doctrine->dbal()->defaultConnection('default');
135+
136+ // configure these for your database server
137+ $doctrine->dbal()
138+ ->connection('default')
139+ ->url('%env(resolve:DATABASE_URL)%')
140+ ->driver('pdo_mysql')
141+ ->serverVersion('5.7')
142+ ->charset('utf8mb4');
143+
144+ // configure these for your database server
145+ $doctrine->dbal()
146+ ->connection('customer')
147+ ->url('%env(resolve:DATABASE_CUSTOMER_URL)%')
148+ ->driver('pdo_mysql')
149+ ->serverVersion('5.7')
150+ ->charset('utf8mb4');
151+
152+ $doctrine->orm()->defaultEntityManager('default');
153+ $emDefault = $doctrine->orm()->entityManager('default');
154+ $emDefault->connection('default');
155+ $emDefault->mapping('Main')
156+ ->isBundle(false)
157+ ->type('annotation')
158+ ->dir('%kernel.project_dir%/src/Entity/Main')
159+ ->prefix('App\Entity\Main')
160+ ->alias('Main');
161+
162+ $emCustomer = $doctrine->orm()->entityManager('customer');
163+ $emCustomer->connection('customer');
164+ $emCustomer->mapping('Customer')
165+ ->isBundle(false)
166+ ->type('annotation')
167+ ->dir('%kernel.project_dir%/src/Entity/Customer')
168+ ->prefix('App\Entity\Customer')
169+ ->alias('Customer')
170+ ;
171+ };
182172
183173 In this case, you've defined two entity managers and called them ``default ``
184174and ``customer ``. The ``default `` entity manager manages entities in the
0 commit comments