sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
450 stars 496 forks source link

Error: Unknown column type "json" requested #1372

Closed lukepass closed 6 years ago

lukepass commented 6 years ago

Hello, on an empty project with Symfony 2.8 I installed Sonata Media Bundle and at the end of the installation guide (https://sonata-project.org/bundles/media/master/doc/reference/installation.html) when i execute:

php app/console doctrine:schema:create

I get this error:

[Doctrine\DBAL\DBALException]                                                
Unknown column type "json" requested. Any Doctrine type that you use has to  
be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a lis  
t of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If   
this error occurs during database introspection then you might have forgot   
to register all database types for a Doctrine Type. Use AbstractPlatform#re  
gisterDoctrineTypeMapping() or have your custom types implement Type#getMap  
pedDatabaseTypes(). If the type name is empty you might have a problem with  
the cache or forgot some mapping information. 

Environment

Symfony 2.8 Empty Project

Sonata packages

$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle              3.30.1 3.30.1 The missing Symfony Admin Generator
sonata-project/block-bundle              3.10.0 3.10.0 Symfony SonataBlockBundle
sonata-project/cache                     2.0.1  2.0.1  Cache library
sonata-project/core-bundle               3.9.0  3.9.0  Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1  2.3.1  Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2  1.0.2  Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.4.0  3.4.0  Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.3.1  2.3.1  Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0  1.8.0  Lightweight Exporter library
sonata-project/media-bundle              3.10.0 3.10.0 Symfony SonataMediaBundle
sonata-project/notification-bundle       3.2.0  3.3.0  Symfony SonataNotificationBundle

Symfony packages

$ composer show --latest 'symfony/*'
symfony/monolog-bundle     v3.1.2  v3.1.2 Symfony MonologBundle
symfony/phpunit-bridge     v2.8.33 v4.0.3 Symfony PHPUnit Bridge
symfony/polyfill-apcu      v1.6.0  v1.6.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu  v1.6.0  v1.6.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring  v1.6.0  v1.6.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70     v1.6.0  v1.6.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util      v1.6.0  v1.6.0 Symfony utilities for portability of PHP codes
symfony/security-acl       v2.8.0  v3.0.1 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.6.7  v3.1.6 Symfony SwiftmailerBundle
symfony/symfony            v2.8.33 v4.0.3 The Symfony PHP framework

PHP version

$ php -v
PHP 7.1.13-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Jan  5 2018 13:26:45) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.13-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

Subject

My config.yml file:

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
    locale: en

framework:
    #esi: ~
    translator: { fallbacks: ['%locale%'] }
    secret: '%secret%'
    router:
        resource: '%kernel.root_dir%/config/routing.yml'
        strict_requirements: ~
    form: ~
    csrf_protection: ~
    validation: { enable_annotations: true }
    #serializer: { enable_annotations: true }
    templating:
        engines: ['twig']
    default_locale: '%locale%'
    trusted_hosts: ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id: ~
    fragments: ~
    http_method_override: true

# Twig Configuration
twig:
    debug: '%kernel.debug%'
    strict_variables: '%kernel.debug%'

# 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.root_dir%/data/data.db3'
        #   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

    dbal:
        types:
            json: Sonata\Doctrine\Types\JsonType

# Swiftmailer Configuration
swiftmailer:
    transport: '%mailer_transport%'
    host: '%mailer_host%'
    username: '%mailer_user%'
    password: '%mailer_password%'
    spool: { type: memory }
    auth_mode: '%mailer_auth_mode%'
    port: '%mailer_port%'

# Sonata Block
sonata_block:
    default_contexts: [cms]
    blocks:
        # enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts: [admin]

# Sonata Media
sonata_media:
    # if you don't use default namespace configuration
    #class:
    #    media:        MyVendor\MediaBundle\Entity\Media
    #    gallery:      MyVendor\MediaBundle\Entity\Gallery
    #    gallery_item: MyVendor\MediaBundle\Entity\GalleryItem
    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

My composer packages:

composer show

cocur/slugify                            v3.0.1  Converts a string into a slug.
doctrine/annotations                     v1.2.7  Docblock Annotations Parser
doctrine/cache                           v1.5.4  Caching library offering an object-oriented API for many cache backends
doctrine/collections                     v1.3.0  Collections Abstraction library
doctrine/common                          v2.5.3  Common Library for Doctrine projects
doctrine/dbal                            v2.5.13 Database Abstraction Layer
doctrine/doctrine-bundle                 1.6.4   Symfony DoctrineBundle
doctrine/doctrine-cache-bundle           1.3.2   Symfony Bundle for Doctrine Cache
doctrine/inflector                       v1.1.0  Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                    1.1.0   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                           v1.0.1  Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm                             v2.4.8  Object-Relational-Mapper for PHP
imagine/imagine                          v0.6.3  Image processing for PHP 5.3
incenteev/composer-parameter-handler     v2.1.2  Composer script handling your ignored parameter file
ircmaxell/password-compat                v1.0.4  A compatibility library for the proposed simplified password hashing algorithm: https://wiki.p...
jdorn/sql-formatter                      v1.2.17 a PHP SQL highlighting library
jms/metadata                             1.6.0   Class/method/property metadata management in PHP
jms/parser-lib                           1.0.0   A library for easily creating recursive-descent parsers.
jms/serializer                           1.10.0  Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle                    2.3.1   Allows you to easily serialize, and deserialize data of any complexity
knplabs/gaufrette                        v0.3.1  PHP5 library that provides a filesystem abstraction layer
knplabs/knp-menu                         2.3.0   An object oriented menu library
knplabs/knp-menu-bundle                  v2.2.1  This bundle provides an integration of the KnpMenu library
kriswallsmith/buzz                       v0.15.2 Lightweight HTTP client
monolog/monolog                          1.23.0  Sends your logs to files, sockets, inboxes, databases and various web services
paragonie/random_compat                  v2.0.11 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpcollection/phpcollection              0.5.0   General-Purpose Collection Library for PHP
phpoption/phpoption                      1.5.0   Option Type for PHP
psr/log                                  1.0.2   Common interface for logging libraries
sensio/distribution-bundle               v4.0.39 Base bundle for Symfony Distributions
sensio/framework-extra-bundle            v3.0.29 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle                  v3.1.7  This bundle generates code for you
sensiolabs/security-checker              v3.0.7  A security checker for your composer.lock
sonata-project/admin-bundle              3.30.1  The missing Symfony Admin Generator
sonata-project/block-bundle              3.10.0  Symfony SonataBlockBundle
sonata-project/cache                     2.0.1   Cache library
sonata-project/core-bundle               3.9.0   Symfony SonataCoreBundle
sonata-project/datagrid-bundle           2.3.1   Symfony SonataDatagridBundle
sonata-project/doctrine-extensions       1.0.2   Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.4.0   Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle       2.3.1   Symfony SonataEasyExtendsBundle
sonata-project/exporter                  1.8.0   Lightweight Exporter library
sonata-project/media-bundle              3.10.0  Symfony SonataMediaBundle
sonata-project/notification-bundle       3.2.0   Symfony SonataNotificationBundle
swiftmailer/swiftmailer                  v5.4.8  Swiftmailer, free feature-rich PHP mailer
symfony/monolog-bundle                   v3.1.2  Symfony MonologBundle
symfony/phpunit-bridge                   v2.8.33 Symfony PHPUnit Bridge
symfony/polyfill-apcu                    v1.6.0  Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu                v1.6.0  Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring                v1.6.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php54                   v1.6.0  Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55                   v1.6.0  Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56                   v1.6.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                   v1.6.0  Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                    v1.6.0  Symfony utilities for portability of PHP codes
symfony/security-acl                     v2.8.0  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle               v2.6.7  Symfony SwiftmailerBundle
symfony/symfony                          v2.8.33 The Symfony PHP framework
twig/extensions                          v1.5.1  Common additional features for Twig that do not directly belong in core
twig/twig                                v1.35.0 Twig, the flexible, fast, and secure template language for PHP
zendframework/zenddiagnostics            v1.1.0  A set of components for performing diagnostic tests in PHP applications
greg0ire commented 6 years ago

I don't think you actually need this:

    dbal:
        types:
            json: Sonata\Doctrine\Types\JsonType

since there's a native json type (thanks @Taluu )

What docs did you follow?

lukepass commented 6 years ago

I noticed that I duplicated the dbal key. Adding types key to the previous dbal solved the problem.

Thanks.

thsking commented 6 years ago

Solved my problem too, thank !!