4

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?

Václav Stummer
  • 349
  • 2
  • 8
  • 21
  • It's unfortunate but the FOSUserBundle is not yet compatible with Symfony 4. Even if you get past this, other problems will arise. Might want to wait a few months then try again. – Cerad Feb 28 '18 at 16:53
  • I noticed that but is there some else solution like FOSUserBundle? I am new in this type of programming. – Václav Stummer Feb 28 '18 at 17:08
  • The SecurityBundle gives you 98% of the functionality you need. Just a question of wiring up a few things. Perhaps the most amusing aspect of the FOSUserBundle is that almost everyone needs to customize it and figuring out how to customize it takes far more effort than just writing the code yourself. – Cerad Feb 28 '18 at 17:21

2 Answers2

8

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.x i suggest checking out this article: Configuration Structure - taken from symfony blog A new way to develop applications

6

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

Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171