Symfony 3.2.7 and sonata media bundle installation
我正在尝试在symfony 3.2.7 / php7 / doctrine环境上安装Sonata媒体包。
我正在阅读此文档:https://sonata-project.org/bundles/media/3-x/doc/reference/installation.html
但是当我使用此命令行生成DB时,我出错了:php bin / console doctrine:schema:update --force
错误消息:
1 2 3 4 5 6 | [Doctrine\\DBAL\\DBALException] Unknown column type"json" requested. Any Doctrine type that you use has to be registered with \\Doctrine\\DBAL\\Types\\Type::addT ype(). You can get a list of all the known types with \\Doctrine\\DBAL\\Types\\Type::getTypesMap(). If this error occurs during da tabase introspection then you might have forgot to register all database types for a Doctrine Type. Use AbstractPlatform#regis terDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes(). If the type name is empty you migh t have a problem with the cache or forgot some mapping information. |
此外,当我键入此命令行时:php bin /控制台学说:schema:validate
我有以下消息:
1 2 3 4 5 | [Mapping] FAIL - The entity-class 'Sonata\\MediaBundle\\Entity\\BaseMedia' mapping is invalid: * The field 'Sonata\\MediaBundle\\Entity\\BaseMedia#providerMetadata' uses a non-existant type 'json'. [Mapping] FAIL - The entity-class 'Application\\Sonata\\MediaBundle\\Entity\\Media' mapping is invalid: * The field 'Application\\Sonata\\MediaBundle\\Entity\\Media#providerMetadata' uses a non-existant type 'json'. |
这是我的composer.json:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | "require": { "php":">=5.5.9", "symfony/symfony":"3.2.*", "doctrine/orm":"^2.5", "doctrine/doctrine-bundle":"^1.6", "doctrine/doctrine-cache-bundle":"^1.2", "symfony/swiftmailer-bundle":"^2.3.10", "symfony/monolog-bundle":"^3.0.2", "symfony/polyfill-apcu":"^1.0", "sensio/distribution-bundle":"^5.0", "sensio/framework-extra-bundle":"^3.0.2", "incenteev/composer-parameter-handler":"^2.0", "symfony/intl":"^3", "hautelook/alice-bundle":"^1.3", "doctrine/doctrine-fixtures-bundle":"^2.3", "friendsofsymfony/user-bundle":"~2.0@dev", "jms/translation-bundle":"dev-master", "jms/i18n-routing-bundle":"dev-master", "sonata-project/admin-bundle":"^3.16", "sonata-project/doctrine-orm-admin-bundle":"^3.1", "sonata-project/media-bundle":"^3.5" }, |
你知道我在做什么错吗?
这是我的config.yml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | doctrine: orm: entity_managers: default: mappings: ApplicationSonataMediaBundle: ~ SonataMediaBundle: ~ dbal: types: json: Sonata\\Doctrine\\Types\\JsonType sonata_media: # if you don't use default namespace configuration #class: # media: MyVendor\\MediaBundle\\Entity\\Media # gallery: MyVendor\\MediaBundle\\Entity\\Gallery # gallery_has_media: MyVendor\\MediaBundle\\Entity\\GalleryHasMedia db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here default_context: default # you need to set a context contexts: default: # the default context is mandatory providers: - sonata.media.provider.dailymotion - sonata.media.provider.youtube - sonata.media.provider.image - sonata.media.provider.file - sonata.media.provider.vimeo formats: small: { width: 100 , quality: 70} big: { width: 500 , quality: 70} cdn: server: path: /uploads/media # http://media.sonata-project.org/ filesystem: local: directory: "%kernel.root_dir%/../web/uploads/media" create: false |
您的config.yml标识错误
根据https://sonata-project.org/bundles/media/3-x/doc/reference/installation.html
,这应该是正确的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | doctrine: orm: entity_managers: default: mappings: ApplicationSonataMediaBundle: ~ SonataMediaBundle: ~ dbal: types: json: Sonata\\Doctrine\\Types\\JsonType sonata_media: # if you don't use default namespace configuration #class: # media: MyVendor\\MediaBundle\\Entity\\Media # gallery: MyVendor\\MediaBundle\\Entity\\Gallery # gallery_has_media: MyVendor\\MediaBundle\\Entity\\GalleryHasMedia db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here default_context: default # you need to set a context contexts: default: # the default context is mandatory providers: - sonata.media.provider.dailymotion - sonata.media.provider.youtube - sonata.media.provider.image - sonata.media.provider.file - sonata.media.provider.vimeo formats: small: { width: 100 , quality: 70} big: { width: 500 , quality: 70} cdn: server: path: /uploads/media # http://media.sonata-project.org/ filesystem: local: directory: "%kernel.root_dir%/../web/uploads/media" create: false |