首页 > 解决方案 > 构建缓存后不考虑 Symfony Doctrine 配置自定义类型

问题描述

你好,我在 Symfony4(4.0.9)上的 Doctrine 有一个奇怪的行为,在控制台中,缓存是由第一次运行某些命令(在开发环境中)生成的,在 config/packages/doctrine.yml 中定义的自定义类型不再考虑。为什么会发生这种情况,我该如何解决?

其他可能有用的信息:我从 Symfony2 应用程序复制了应用程序代码(控制器、实体等),并将其导入到新的 Symfony 4 应用程序中,因为我正在使其与 Symfony 4 兼容。另外,我在应用程序的网络版本上没有这种行为(始终识别自定义类型)

# config/packages/doctrine.yml
doctrine:
    dbal:
        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.7'
        charset: utf8mb4
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci

        url: '%env(resolve:DATABASE_URL)%'
        types:
            enumprofilecompletionstep: 'App\DBAL\EnumProfileCompletionStepPossibleValuesType'
            enumsection: 'App\DBAL\EnumSectionType'
            enumsex: 'App\DBAL\EnumSexType'
            enumstatus: 'App\DBAL\EnumStatusType'
            phone_number: 'Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType'
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

谢谢你的时间,先生POC

标签: symfony

解决方案


推荐阅读