配置好entity后,编写anotation注释,来声明‘元数据’(metadata)的参数
然后输入执行映射命令行时,出现了以下错误信息
PS D:\symfony_project\my_project_name> php bin/console doctrine:schema:validate
[Mapping] OK - The mapping files are correct.
In AbstractPlatform.php line 423:
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.
doctrine:schema:validate [--skip-mapping] [--skip-sync] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
百度了一轮,终于找到解决办法
可以再config.yml里面修改配置
本来config.yml中Doctrine的配置
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
修改后的配置如下:
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite'
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
#path: '%database_path%'
mapping_types:
enum: string
set: string
varbinary: string
tinyblob: text
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
以后碰到相同问题,把不支持的几个类型 enum,set等等换成 mysql常用的基本类型 就好了
参考博文:原 SF2 : doctrine 报错处理办法: Unknown database type enum requested
原创文章:doctrine 报错处理办法: Unknown database type enum requested