From c75af4906933bebff6bb53639a1b24a917ed0c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Thu, 4 Jan 2024 12:29:59 +0100 Subject: [PATCH 1/5] Add PHP config examples --- docs/config.rst | 244 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 243 insertions(+), 1 deletion(-) diff --git a/docs/config.rst b/docs/config.rst index 0a81c71a..38d8dd6b 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -48,6 +48,27 @@ Sample Configuration + .. code-block:: php + + use function Symfony\Component\DependencyInjection\Loader\Configurator\env; + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->defaultConnection('default'); + $config->connection('default') + ->server(env('MONGODB_URL')->default('mongodb://localhost:27017')->resolve()) + ->options([]); + + $config->documentManager('default') + ->mapping('AcmeDemoBundle') + ->filter('filter-name') + ->class(\Class\Example\Filter\ODM\ExampleFilter::class) + ->enabled(true) + ->metadataCacheDriver('array'); // array, service, apcu, memcached, redis + }; +} + + .. tip:: If each environment requires a different MongoDB connection URI, you can @@ -66,7 +87,7 @@ Sample Configuration default: server: '%env(resolve:MONGODB_URL)%' -If you wish to use memcache to cache your metadata, you need to configure the +If you wish to use memcached to cache your metadata, you need to configure the ``Memcached`` instance; for example, you can do the following: .. configuration-block:: @@ -118,6 +139,29 @@ If you wish to use memcache to cache your metadata, you need to configure the + .. code-block:: php + + use Symfony\Component\Cache\Adapter\MemcachedAdapter; + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->defaultConnection('default'); + $config->connection('default') + ->server('mongodb://localhost:27017'); + + $config->documentManager('default') + ->mapping('AcmeDemoBundle') + ->filter('filter-name') + ->class('Class\Example\Filter\ODM\ExampleFilter') + ->enabled(true) + ->metadataCacheDriver() + ->type('memcached') + ->class(MemcachedAdapter::class) + ->host('localhost') + ->port(11211) + ->instanceClass(\Memcached::class) + ; + }; Mapping Configuration --------------------- @@ -214,6 +258,34 @@ The following configuration shows a bunch of mapping examples: + .. code-block:: php + + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->documentManager('default') + ->mapping('MyBundle1') + ->mapping('MyBundle2') + ->type('xml') + ->mapping('MyBundle3') + ->type('attribute') + ->dir(__DIR__.'/../src/Document') + ->mapping('MyBundle4') + ->type('xml') + ->dir(__DIR__.'/../config/doctrine/mapping') + ->mapping('MyBundle5') + ->type('xml') + ->dir('my-bundle-mappings-dir') + ->alias('BundleAlias') + ->mapping('MyBundle6') + ->type('xml') + ->dir('%kernel.project_dir%/src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents') + ->prefix('DoctrineExtensions\\Documents\\') + ->alias('DExt') + ; + } + + Custom Types ------------ @@ -244,6 +316,17 @@ your documents. + .. code-block:: php + + use Fully\Qualified\Class\Name; + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->type('custom_type') + ->class(Name::class) + ; + } + Filters ------- @@ -298,6 +381,24 @@ Filters may be registered with a document manager by using the following syntax: + .. code-block:: php + + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->documentManager('default') + ->filter('basic_filter') + ->class('Vendor\Filter\BasicFilter') + ->enabled(true) + ->filter('complex_filter') + ->class('Vendor\Filter\ComplexFilter') + ->enabled(true) + ->parameter('author', 'bob') + ->parameter('comments', [ '$gte' => 10 ]) + ->parameter('tags', [ '$in' => [ 'foo', 'bar' ] ]) + ; + } + .. note:: Unlike ORM, query parameters in MongoDB ODM may be non-scalar values. Since @@ -372,6 +473,35 @@ following syntax: + .. code-block:: php + + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->defaultDatabase('hello_%kernel.environment%'); + $config->defaultDocumentManager('dm2'); + $config->defaultConnection('dm2'); + $config->proxyNamespace('MongoDBODMProxies'); + $config->autoGenerateProxyClasses(true); + + $config->connection('conn1') + ->server('mongodb://localhost:27017'); + + $config->connection('conn2') + ->server('mongodb://localhost:27017'); + + $config->documentManager('dm1') + ->metadataCacheDriver('array') + ->connection('conn1') + ->database('db1') + ->mapping('AcmeDemoBundle'); + + $config->documentManager('dm2') + ->connection('conn2') + ->database('db2') + ->mapping('AcmeHelloBundle'); + }; + Now you can retrieve the configured services connection services: .. code-block:: php @@ -419,6 +549,15 @@ string as a comma separated list and using ``replicaSet`` option. + .. code-block:: php + + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->connection('default') + ->server('mongodb://mongodb-01:27017,mongodb-02:27017,mongodb-03:27017/?replicaSet=replSetName'); + }; + Where mongodb-01, mongodb-02 and mongodb-03 are the machine hostnames. You can also use IP addresses if you prefer. @@ -472,6 +611,20 @@ Otherwise you will get a *auth failed* exception. + .. code-block:: php + + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->connection('default') + ->server('mongodb://localhost:27017') + ->options([ + 'username' => 'someuser', + 'password' => 'somepass', + 'authSource' => 'db_you_have_access_to', + ]); + }; + Specifying a context service ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -492,6 +645,20 @@ create a service that creates your logging context: arguments: - { ssl: { verify_expiry: true } } + .. code-block:: php + + use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; + + return static function (ContainerConfigurator $container): void { + $container->services() + ->set('app.mongodb.context_service', 'resource') + ->factory('stream_context_create') + ->args([ + ['ssl' => ['verify_expiry' => true]], + ]) + ; + }; + Note: the ``class`` option is not used when creating the service, but has to be provided for the service definition to be valid. @@ -529,6 +696,18 @@ You can then use this service in your configuration: + .. code-block:: php + + use Symfony\Config\DoctrineMongodbConfig; + + return static function (DoctrineMongodbConfig $config): void { + $config->connection('default') + ->server('mongodb://localhost:27017') + ->driverOptions([ + 'context' => 'app.mongodb.context_service', + ]); + }; + Full Default Configuration -------------------------- @@ -684,6 +863,69 @@ Full Default Configuration + .. code-block:: php + + use Symfony\Config\DoctrineConfig; + + return static function (DoctrineConfig $config): void { + $config->autoGenerateHydratorClasses(0); + $config->autoGenerateProxyClasses(0); + $config->defaultConnection(''); + $config->defaultDatabase('default'); + $config->defaultDocumentManager(''); + $config->hydratorDir('%kernel.cache_dir%/doctrine/odm/mongodb/Hydrators'); + $config->hydratorNamespace('Hydrators'); + $config->proxyDir('%kernel.cache_dir%/doctrine/odm/mongodb/Proxies'); + $config->proxyNamespace('Proxies'); + $config->fixtureLoader('Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader'); + + $config->documentManager('id') + ->connection('') + ->database('') + ->defaultDocumentRepositoryClass('') + ->defaultGridfsRepositoryClass('') + ->repositoryFactory('') + ->logging(true) + ->autoMapping(false) + ->metadataCacheDriver() + ->type('') + ->class('') + ->host('') + ->port('') + ->instanceClass('') + ->mapping('name') + ->type('') + ->dir('') + ->prefix('') + ->alias('') + ->isBundle('') + ->profiler() + ->enabled(true) + ->pretty(false) + ; + + $config->type('custom_type') + ->class('Fully\Qualified\Class\Name'); + + $config->connection('id') + ->server('mongodb://localhost') + ->options([ + 'authMechanism' => '', + 'connectTimeoutMS' => '', + 'db' => '', + 'authSource' => '', + 'journal' => '', + 'password' => '', + 'readPreference' => '', + 'replicaSet' => '', + 'socketTimeoutMS' => '', + 'ssl' => '', + 'username' => '', + 'w' => '', + 'wTimeoutMS' => '', + ]); + }; + .. _`Custom types`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/current/reference/custom-mapping-types.html .. _`define it as an environment variable`: https://symfony.com/doc/current/configuration.html#configuration-based-on-environment-variables .. _`connection string`: https://docs.mongodb.com/manual/reference/connection-string/#urioption.authSource From 46c844c8e990f455aaf370c24bd4d8a17f28a478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 5 Jan 2024 12:33:04 +0100 Subject: [PATCH 2/5] Review --- docs/config.rst | 98 +++++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 38d8dd6b..78803720 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -51,14 +51,15 @@ Sample Configuration .. code-block:: php use function Symfony\Component\DependencyInjection\Loader\Configurator\env; + use function Symfony\Component\DependencyInjection\Loader\Configurator\param; use Symfony\Config\DoctrineMongodbConfig; return static function (DoctrineMongodbConfig $config): void { - $config->defaultConnection('default'); $config->connection('default') ->server(env('MONGODB_URL')->default('mongodb://localhost:27017')->resolve()) ->options([]); + $config->defaultDatabase('hello_' . param('kernel.environment')); $config->documentManager('default') ->mapping('AcmeDemoBundle') ->filter('filter-name') @@ -141,19 +142,18 @@ If you wish to use memcached to cache your metadata, you need to configure the .. code-block:: php + use function Symfony\Component\DependencyInjection\Loader\Configurator\param; use Symfony\Component\Cache\Adapter\MemcachedAdapter; use Symfony\Config\DoctrineMongodbConfig; return static function (DoctrineMongodbConfig $config): void { - $config->defaultConnection('default'); + $config->defaultDatabase('hello_' . param('kernel.environment')); $config->connection('default') - ->server('mongodb://localhost:27017'); + ->server('mongodb://localhost:27017') + ->options([]); $config->documentManager('default') ->mapping('AcmeDemoBundle') - ->filter('filter-name') - ->class('Class\Example\Filter\ODM\ExampleFilter') - ->enabled(true) ->metadataCacheDriver() ->type('memcached') ->class(MemcachedAdapter::class) @@ -260,6 +260,7 @@ The following configuration shows a bunch of mapping examples: .. code-block:: php + use function Symfony\Component\DependencyInjection\Loader\Configurator\param; use Symfony\Config\DoctrineMongodbConfig; return static function (DoctrineMongodbConfig $config): void { @@ -269,17 +270,17 @@ The following configuration shows a bunch of mapping examples: ->type('xml') ->mapping('MyBundle3') ->type('attribute') - ->dir(__DIR__.'/../src/Document') + ->dir('Documents/') ->mapping('MyBundle4') ->type('xml') - ->dir(__DIR__.'/../config/doctrine/mapping') + ->dir('Resources/config/doctrine/mapping') ->mapping('MyBundle5') ->type('xml') ->dir('my-bundle-mappings-dir') ->alias('BundleAlias') - ->mapping('MyBundle6') + ->mapping('doctrine_extensions') ->type('xml') - ->dir('%kernel.project_dir%/src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents') + ->dir(param('kernel.project_dir') . '/src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents') ->prefix('DoctrineExtensions\\Documents\\') ->alias('DExt') ; @@ -318,12 +319,11 @@ your documents. .. code-block:: php - use Fully\Qualified\Class\Name; use Symfony\Config\DoctrineMongodbConfig; return static function (DoctrineMongodbConfig $config): void { $config->type('custom_type') - ->class(Name::class) + ->class(\Fully\Qualified\Class\Name::class) ; } @@ -388,11 +388,11 @@ Filters may be registered with a document manager by using the following syntax: return static function (DoctrineMongodbConfig $config): void { $config->documentManager('default') ->filter('basic_filter') - ->class('Vendor\Filter\BasicFilter') + ->class(\Vendor\Filter\BasicFilter::class) ->enabled(true) ->filter('complex_filter') - ->class('Vendor\Filter\ComplexFilter') - ->enabled(true) + ->class(\Vendor\Filter\ComplexFilter::class) + ->enabled(false) ->parameter('author', 'bob') ->parameter('comments', [ '$gte' => 10 ]) ->parameter('tags', [ '$in' => [ 'foo', 'bar' ] ]) @@ -475,14 +475,13 @@ following syntax: .. code-block:: php + use function Symfony\Component\DependencyInjection\Loader\Configurator\param; use Symfony\Config\DoctrineMongodbConfig; return static function (DoctrineMongodbConfig $config): void { - $config->defaultDatabase('hello_%kernel.environment%'); + $config->defaultDatabase('hello_' . param('kernel.environment')); $config->defaultDocumentManager('dm2'); $config->defaultConnection('dm2'); - $config->proxyNamespace('MongoDBODMProxies'); - $config->autoGenerateProxyClasses(true); $config->connection('conn1') ->server('mongodb://localhost:27017'); @@ -491,9 +490,9 @@ following syntax: ->server('mongodb://localhost:27017'); $config->documentManager('dm1') - ->metadataCacheDriver('array') ->connection('conn1') ->database('db1') + ->metadataCacheDriver('array') ->mapping('AcmeDemoBundle'); $config->documentManager('dm2') @@ -563,7 +562,7 @@ can also use IP addresses if you prefer. .. tip:: - Please refer to `Replica Sets`_ manual of MongoDB PHP Driver for futher details. + Please refer to `Replica Sets`_ manual of MongoDB PHP Driver for further details. Using Authentication on a Database Level @@ -815,7 +814,6 @@ Full Default Configuration hydrator-namespace="Hydrators" proxy-dir="%kernel.cache_dir%/doctrine/odm/mongodb/Proxies" proxy-namespace="Proxies" - fixture-loader="Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader" > autoGenerateHydratorClasses(0); $config->autoGenerateProxyClasses(0); $config->defaultConnection(''); @@ -877,7 +875,6 @@ Full Default Configuration $config->hydratorNamespace('Hydrators'); $config->proxyDir('%kernel.cache_dir%/doctrine/odm/mongodb/Proxies'); $config->proxyNamespace('Proxies'); - $config->fixtureLoader('Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader'); $config->documentManager('id') ->connection('') @@ -888,11 +885,11 @@ Full Default Configuration ->logging(true) ->autoMapping(false) ->metadataCacheDriver() - ->type('') - ->class('') - ->host('') - ->port('') - ->instanceClass('') + ->type(null) + ->class(null) + ->host(null) + ->port(null) + ->instanceClass(null) ->mapping('name') ->type('') ->dir('') @@ -909,21 +906,36 @@ Full Default Configuration $config->connection('id') ->server('mongodb://localhost') + ->driverOptions([ + 'context' => null, // stream context to use for connection + ]) ->options([ - 'authMechanism' => '', - 'connectTimeoutMS' => '', - 'db' => '', - 'authSource' => '', - 'journal' => '', - 'password' => '', - 'readPreference' => '', - 'replicaSet' => '', - 'socketTimeoutMS' => '', - 'ssl' => '', - 'username' => '', - 'w' => '', - 'wTimeoutMS' => '', - ]); + 'authMechanism' => null, + 'connectTimeoutMS' => null, + 'db' => null, + 'authSource' => null, + 'journal' => null, + 'password' => null, + 'readPreference' => null, + 'readPreferenceTags' => null, + 'replicaSet' => null, // replica set name + 'socketTimeoutMS' => null, + 'ssl' => null, + 'tls' => null, + 'tlsAllowInvalidCertificates' => null, + 'tlsAllowInvalidHostnames' => null, + 'tlsCAFile' => null, + 'tlsCertificateKeyFile' => null, + 'tlsCertificateKeyFilePassword' => null, + 'tlsDisableCertificateRevocationCheck' => null, + 'tlsDisableOCSPEndpointCheck' => null, + 'tlsInsecure' => null, + 'username' => null, + 'retryReads' => null, + 'retryWrites' => null, + 'w' => null, + 'wTimeoutMS' => null, + ]) }; .. _`Custom types`: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/current/reference/custom-mapping-types.html From 753209b02615fced9986d2296683dcde74e0f5c1 Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Fri, 22 Dec 2023 17:35:18 +0100 Subject: [PATCH 3/5] Remove bundle examples --- docs/config.rst | 44 +++++++++---------- docs/installation.rst | 2 +- .../DoctrineMongoDBExtension.php | 14 +++--- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 78803720..f2c032dc 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -18,7 +18,7 @@ Sample Configuration document_managers: default: mappings: - AcmeDemoBundle: ~ + App: ~ filters: filter-name: class: Class\Example\Filter\ODM\ExampleFilter @@ -41,7 +41,7 @@ Sample Configuration - + @@ -105,7 +105,7 @@ If you wish to use memcached to cache your metadata, you need to configure the document_managers: default: mappings: - AcmeDemoBundle: ~ + App: ~ metadata_cache_driver: type: memcached class: Symfony\Component\Cache\Adapter\MemcachedAdapter @@ -125,7 +125,7 @@ If you wish to use memcached to cache your metadata, you need to configure the - + Symfony\Component\Cache\Adapter\MemcachedAdapter localhost @@ -182,9 +182,9 @@ can control. The following configuration options exist for a mapping: - ``prefix`` A common namespace prefix that all documents of this mapping share. This prefix should never conflict with prefixes of other defined mappings otherwise some of your documents cannot be found by Doctrine. This - option defaults to the bundle namespace + ``Document``, for example for an - application bundle called ``AcmeHelloBundle``, the prefix would be - ``Acme\HelloBundle\Document``. + option defaults to the application namespace + ``Document``, for example + for an application called ``App``, the prefix would be + ``App\Document``. - ``alias`` Doctrine offers a way to alias document namespaces to simpler, shorter names to be used in queries or for Repository access. @@ -219,14 +219,14 @@ The following configuration shows a bunch of mapping examples: document_managers: default: mappings: - MyBundle1: ~ - MyBundle2: xml - MyBundle3: { type: attribute, dir: Documents/ } - MyBundle4: { type: xml, dir: Resources/config/doctrine/mapping } - MyBundle5: + App: ~ + App2: xml + App3: { type: attribute, dir: Documents/ } + App4: { type: xml, dir: config/doctrine/mapping } + App5: type: xml - dir: my-bundle-mappings-dir - alias: BundleAlias + dir: my-app-mappings-dir + alias: AppAlias doctrine_extensions: type: xml dir: "%kernel.project_dir%/src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents" @@ -245,10 +245,10 @@ The following configuration shows a bunch of mapping examples: - - - - + + + + - + - + diff --git a/docs/installation.rst b/docs/installation.rst index 7521c465..54b8add0 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -35,7 +35,7 @@ To install DoctrineMongoDBBundle with Composer run the following command: Enable the Bundle ----------------- -Your bundle should be automatically enabled if you use Flex. +The bundle should be automatically enabled if you use Flex. Otherwise, you'll need to manually enable the bundle by adding the following line in the ``config/bundles.php`` file of your project: diff --git a/src/DependencyInjection/DoctrineMongoDBExtension.php b/src/DependencyInjection/DoctrineMongoDBExtension.php index 18b3476b..ebd224da 100644 --- a/src/DependencyInjection/DoctrineMongoDBExtension.php +++ b/src/DependencyInjection/DoctrineMongoDBExtension.php @@ -462,14 +462,14 @@ private function normalizeDriverOptions(array $connection): array * * doctrine_mongodb: * mappings: - * MyBundle1: ~ - * MyBundle2: xml - * MyBundle3: { type: attribute } - * MyBundle4: { type: xml, dir: Resources/config/doctrine/mapping } - * MyBundle5: + * App1: ~ + * App2: xml + * App3: { type: attribute } + * App4: { type: xml, dir: config/doctrine/mapping } + * App5: * type: xml - * dir: [bundle-mappings1/, bundle-mappings2/] - * alias: BundleAlias + * dir: [app-mappings1/, app-mappings2/] + * alias: AppAlias * arbitrary_key: * type: xml * dir: %kernel.dir%/../src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents From d1f97002c7252f9b05d99448ab500855fe34baa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 8 Jan 2024 16:00:10 +0100 Subject: [PATCH 4/5] Apply Bundle structure removal --- docs/config.rst | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index f2c032dc..d4f7eaae 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -61,10 +61,10 @@ Sample Configuration $config->defaultDatabase('hello_' . param('kernel.environment')); $config->documentManager('default') - ->mapping('AcmeDemoBundle') + ->mapping('App') ->filter('filter-name') - ->class(\Class\Example\Filter\ODM\ExampleFilter::class) - ->enabled(true) + ->class(\Class\Example\Filter\ODM\ExampleFilter::class) + ->enabled(true) ->metadataCacheDriver('array'); // array, service, apcu, memcached, redis }; } @@ -153,7 +153,7 @@ If you wish to use memcached to cache your metadata, you need to configure the ->options([]); $config->documentManager('default') - ->mapping('AcmeDemoBundle') + ->mapping('App') ->metadataCacheDriver() ->type('memcached') ->class(MemcachedAdapter::class) @@ -265,19 +265,19 @@ The following configuration shows a bunch of mapping examples: return static function (DoctrineMongodbConfig $config): void { $config->documentManager('default') - ->mapping('MyBundle1') - ->mapping('MyBundle2') + ->mapping('App') + ->mapping('App2') ->type('xml') - ->mapping('MyBundle3') + ->mapping('App3') ->type('attribute') ->dir('Documents/') - ->mapping('MyBundle4') + ->mapping('App4') ->type('xml') - ->dir('Resources/config/doctrine/mapping') - ->mapping('MyBundle5') + ->dir('config/doctrine/mapping') + ->mapping('App5') ->type('xml') - ->dir('my-bundle-mappings-dir') - ->alias('BundleAlias') + ->dir('my-app-mappings-dir') + ->alias('AppAlias') ->mapping('doctrine_extensions') ->type('xml') ->dir(param('kernel.project_dir') . '/src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Documents') @@ -493,12 +493,12 @@ following syntax: ->connection('conn1') ->database('db1') ->metadataCacheDriver('array') - ->mapping('AcmeDemoBundle'); + ->mapping('App'); $config->documentManager('dm2') ->connection('conn2') ->database('db2') - ->mapping('AcmeHelloBundle'); + ->mapping('AnotherApp'); }; Now you can retrieve the configured services connection services: From 8a4d197b2300dcceee3fce483cd763ffb3dcf322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 8 Jan 2024 16:04:32 +0100 Subject: [PATCH 5/5] Replace sample configuration from flex recipes examples https://github.com/symfony/recipes-contrib/blob/main/doctrine/mongodb-odm-bundle/4.4/config/packages/doctrine_mongodb.yaml --- docs/config.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index d4f7eaae..f3cec7f7 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -18,11 +18,11 @@ Sample Configuration document_managers: default: mappings: - App: ~ - filters: - filter-name: - class: Class\Example\Filter\ODM\ExampleFilter - enabled: true + App: + is_bundle: false + dir: '%kernel.project_dir%/src/Document' + prefix: 'App\Document' + alias: App metadata_cache_driver: array # array, service, apcu, memcached, redis .. code-block:: xml @@ -41,8 +41,7 @@ Sample Configuration - - + @@ -62,9 +61,10 @@ Sample Configuration $config->defaultDatabase('hello_' . param('kernel.environment')); $config->documentManager('default') ->mapping('App') - ->filter('filter-name') - ->class(\Class\Example\Filter\ODM\ExampleFilter::class) - ->enabled(true) + ->isBundle(false) + ->dir(param('kernel.project_dir') . '/src/Document') + ->prefix('App\\Document') + ->alias('App') ->metadataCacheDriver('array'); // array, service, apcu, memcached, redis }; }