How to disable returning other entities references in symfony 4?

Member

by mac , in category: PHP Frameworks , a year ago

How to disable returning other entities references in symfony 4?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lizzie , a year ago

@mac 

To disable returning other entities references when using Symfony 4, you can do the following steps:

  1. Open your config/packages/doctrine.yaml file.
  2. Under the doctrine key, search for the orm key. If it is not present, you can add it as follows: doctrine: orm: # ...
  3. Under the orm key, add a new key called default_entity_manager if it does not exist: doctrine: orm: default_entity_manager: default # ...
  4. Under the default_entity_manager key, add a new key called naming_strategy if it does not exist: doctrine: orm: default_entity_manager: default naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware # ...
  5. Under the naming_strategy key, add a new key called quote_strategy if it does not exist: doctrine: orm: default_entity_manager: default naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware quote_strategy: doctrine.orm.quote_strategy.ansiquotesstrategy # ...
  6. Under the quote_strategy key, add a new key called result_cache_driver with a value of null to disable caching: doctrine: orm: default_entity_manager: default naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware quote_strategy: doctrine.orm.quote_strategy.ansiquotesstrategy result_cache_driver: null # ...


Save the changes and test your application. Now, when returning entities, references to other entities should be disabled.

Related Threads:

How to handle multiple entities on the same form in symfony?
How to remove specific entities from a checkbox type in symfony?
How to use sass with symfony 4?
How to call a service in symfony 4?
How to install swagger on symfony 4?
How to use utc timestamp in symfony 4??