Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony + doctrine: Can only configure "xml", "yml", "php", "staticphp" or "attribute" through the DoctrineBundle

upgrading symfony from 6 to 7 getting this doctrine error

In AbstractDoctrineExtension.php line 229:
                                                                                                                                                                     
  Can only configure "xml", "yml", "php", "staticphp" or "attribute" through the DoctrineBundle. Use your own bundle to configure other metadata drivers. You can r  
  egister them by adding a new driver to the "doctrine.orm.default_metadata_driver" service definition.            

here is my doctrine.yaml file:

doctrine:
    dbal:
        server_version:    '%env(DATABASE_VERSION)%'
        dbname:            '%env(DATABASE_NAME)%'
        host:              '%env(DATABASE_HOST)%'
        port:              '%env(DATABASE_PORT)%'
        user:              '%env(DATABASE_USER)%'
        password:          '%env(DATABASE_PASSWORD)%'
        driver:            '%env(DATABASE_DRIVER)%'
        charset:            UTF8
        options:
            !php/const PDO::MYSQL_ATTR_SSL_KEY: '%DATABASE_PUB_KEY%'
            !php/const PDO::MYSQL_ATTR_SSL_CERT: '%DATABASE_PRIV_KEY%'
            !php/const PDO::MYSQL_ATTR_SSL_CA: '%DATABASE_CA_CERT%'
            !php/const PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT: false

    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
        dql:
            numeric_functions:
                rand: DoctrineExtensions\Query\Mysql\Rand
like image 573
Sam Avatar asked Oct 29 '25 10:10

Sam


1 Answers

The mapping type annotation in the orm configuration has been deprecated in version 6.4. You probably should move to attributes. Rector can help you with that.

like image 118
Christoph Avatar answered Nov 01 '25 13:11

Christoph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!