diff --git a/source/includes/php-frameworks/symfony/Restaurant.php b/source/includes/php-frameworks/symfony/Restaurant.php index 39935abf8..4de8ea778 100644 --- a/source/includes/php-frameworks/symfony/Restaurant.php +++ b/source/includes/php-frameworks/symfony/Restaurant.php @@ -12,7 +12,7 @@ #[ODM\Document(collection: 'restaurants')] class Restaurant { - #[ODM\Field] + #[ODM\Id] public ?string $id = null; #[ODM\Field] diff --git a/source/includes/php-frameworks/symfony/RestaurantController.php b/source/includes/php-frameworks/symfony/RestaurantController.php index 17318edfb..15bd07c33 100644 --- a/source/includes/php-frameworks/symfony/RestaurantController.php +++ b/source/includes/php-frameworks/symfony/RestaurantController.php @@ -20,7 +20,7 @@ class RestaurantController extends AbstractController public function __construct(DocumentManager $dm, LoggerInterface $logger) { - $this->dm = $logger; + $this->dm = $dm; $this->logger = $logger; } diff --git a/source/includes/php-frameworks/symfony/doctrine_mongodb.yaml b/source/includes/php-frameworks/symfony/doctrine_mongodb.yaml new file mode 100644 index 000000000..0937bbf8f --- /dev/null +++ b/source/includes/php-frameworks/symfony/doctrine_mongodb.yaml @@ -0,0 +1,18 @@ +doctrine_mongodb: + auto_generate_proxy_classes: true + auto_generate_hydrator_classes: true + connections: + default: + server: "%env(resolve:MONGODB_URL)%" + default_database: "%env(resolve:MONGODB_DB)%" + document_managers: + default: + auto_mapping: true + mappings: + App: + dir: "%kernel.project_dir%/src/Document" + mapping: true + type: attribute + prefix: 'App\Document' + is_bundle: false + alias: App diff --git a/source/php-frameworks/symfony.txt b/source/php-frameworks/symfony.txt index dc15aeb24..5dea28f2e 100644 --- a/source/php-frameworks/symfony.txt +++ b/source/php-frameworks/symfony.txt @@ -184,27 +184,10 @@ Configure the ODM In the ``config/packages`` directory, replace the contents of your ``doctrine_mongodb.yaml`` file with the following code: -.. code-block:: yaml +.. literalinclude:: /includes/php-frameworks/symfony/doctrine_mongodb.yaml :caption: config/packages/doctrine_mongodb.yaml + :language: yaml - doctrine_mongodb: - auto_generate_proxy_classes: true - auto_generate_hydrator_classes: true - connections: - default: - server: '%env(resolve:MONGODB_URL)' - default_database: '%env(resolve:MONGODB_DB)%' - document_managers: - default: - auto_mapping: true - mappings: - App: - dir: '%kernel.project_dir%/src/Document' - mapping: true - type: attribute - prefix: 'App\Document' - is_bundle: false - alias: App Install Frontend Dependency ~~~~~~~~~~~~~~~~~~~~~~~~~~~