1

I had this message error 4 hours ago I tried to resolved but I didn't know where is the problem may all files are truly configured?

the message Error:

[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized options "db_driver, firewall_name, user_class" under "fos_user"

config.yml:

    #Fos
fos_user:
    db_driver: orm
    firewall_name: main
    user_class: Fos\UserBundle\Entity\User

AppKernel.php:

   <?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new AppBundle\AppBundle(),
            new Fos\UserBundle\FosUserBundle(),
        ];

        if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
            $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
            $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
            $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
            $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
        }

        return $bundles;
    }

    public function getRootDir()
    {
        return __DIR__;
    }

    public function getCacheDir()
    {
        return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
    }

    public function getLogDir()
    {
        return dirname(__DIR__).'/var/logs';
    }

    public function registerContainerConfiguration(LoaderInterface $loader)
    {
        $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
    }
}
5
  • Are you using Doctrine or Propel? Commented Feb 21, 2016 at 18:03
  • i use Doctrine ORM , still now , i didn't resolve that Commented Feb 21, 2016 at 18:51
  • Try this: # app/config/config.yml framework: translator: ~ Commented Feb 21, 2016 at 18:57
  • And create User Entity in your FooBundle. Commented Feb 21, 2016 at 18:58
  • yes i have it also ... i have many projects that are work good with those configurations , but this one i don't know what is the problem Commented Feb 21, 2016 at 19:01

1 Answer 1

1

FOSUserBundle installation:

For Doctrine ORM Entity User class(You have to create new Class):

<?php
// src/AppBundle/Entity/User.php
namespace AppBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
    /**
    * @ORM\Id
    * @ORM\Column(type="integer")
    * @ORM\GeneratedValue(strategy="AUTO")
    */
    protected $id;

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }
}

Your security.yml:

# app/config/security.yml
security:
    encoders:
       FOS\UserBundle\Model\UserInterface: bcrypt

    role_hierarchy:
       ROLE_ADMIN:       ROLE_USER
       ROLE_SUPER_ADMIN: ROLE_ADMIN

    providers:
       fos_userbundle:
           id: fos_user.user_provider.username

    firewalls:
       main:
           pattern: ^/
           form_login:
                provider: fos_userbundle
                csrf_token_generator: security.csrf.token_manager

           logout:       true
           anonymous:    true

    access_control:
       - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
       - { path: ^/admin/, role: ROLE_ADMIN }

Config config.yml:

# app/config/config.yml
fos_user:
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: AppBundle\Entity\User

Here AppBundle\Entity\User class that you created new class

Add to Routing app/config/routing.yml:

# app/config/routing.yml
fos_user:
    resource: "@FOSUserBundle/Resources/config/routing/all.xml"

Update your database schema: $ php bin/console doctrine:schema:update --force

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.