在symfony中使用bundle实体的标准方法是什么?



我一直在尝试学习如何在symfony中使用捆绑包,但在使捆绑包的实体出现在我的数据库中时遇到了一些问题。通过将最后几行添加到doctrine.yaml文件中,我终于让它开始工作了。然而,出于某种原因,这似乎不太可能是正确的方法,因为只有当我将"is_bundle"属性设置为false时,它才有效,而如果它是捆绑包中的实体,它可能应该是true。

让这个实体出现在我的数据库中的正确方法是什么?

我的条令文件:

doctrine:
dbal:
default_connection: default
connections:
default:
# configure these for your database server
url: '%env(DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
unix_socket: '/Applications/MAMP/tmp/mysql/mysql.sock'
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
default:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'AppEntity'
alias: default
ch_cookie_consent_bundle:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/vendor/connectholland/cookie-consent-bundle/Entity'
prefix: 'ConnectHollandCookieConsentBundleEntity'
alias: ch_cookie_consent_bundle 

捆绑包本身可以在这里找到:https://github.com/ConnectHolland/cookie-consent-bundle

is_bundle标志指示条令扩展将配置密钥与捆绑包名称相匹配。

在您的情况下,配置应该是

orm:
mappings:
default:
...
CHCookieConsentBundle: # This should match the bundle name (in %kernel.bundles%)
is_bundle: true
alias: ch_cookie_consent_bundle

所有其他配置密钥都是可选的,并且是自动检测的。

最新更新