简体   繁体   中英

FOSUser Bundle The child node “db_driver” at path “fos_user” must be configured

I am trying to update doctrine schema after installation FOSUser Bundle 2.0 but I keep getting this error:

In ArrayNode.php line 238:

The child node "db_driver" at path "fos_user" must be configured. 

File config.yaml is configurated propertly in location /config/config.yaml:

framework:
translator: ~

fos_user:
db_driver: orm 
firewall_name: main
user_class: Entity\User
from_email:
    address: "%mailer_user%"
    sender_name: "%mailer_user%"

I tried to solve it via official tutorial: http://symfony.com/doc/master/bundles/FOSUserBundle/index.html#prerequisites

I tried to do step 5 first and than rerun step 1. But still the same error.

Any ideas?

In symfony 4.x you need to create a bundle_name.yaml file instead of config.yaml So, in this case create file fos_user.yaml in config/packages folder. In that file you place the configuration for FOSUserBundle, like so:

fos_user:
db_driver: orm
firewall_name: main
user_class: Entity\User
from_email:
    address: '%env(resolve:USER_ADDRESS)%'
    sender_name: '%env(resolve:SENDER_NAME)%'
framework:
    templating:
        engines: ['twig', 'php']

Of course, defining the address and sender_name in .env file as constants or provide them directly with: "%mailer_user%"

use composer require friendsofsymfony/user-bundle dev-master or go to their packagist page and get the latest version FOSUserBundle Packagist

That should make it install without errors.

If you need to figure out what has changed between symfony version 3.x and 4.xi suggest checking out this article: Configuration Structure - taken from symfony blog A new way to develop applications

try to indent like this:

fos_user:
    db_driver: orm 
    firewall_name: main
    user_class: Entity\User
    from_email:
        address: "%mailer_user%"
        sender_name: "%mailer_user%"

Because yml file needs to be written and indent well with all spaces necessary

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM