FriendsOfSymfony / FOSUserBundle

Provides user management for your Symfony project. Compatible with Doctrine ORM & ODM, and custom storages.
https://symfony.com/doc/master/bundles/FOSUserBundle/index.html
MIT License
3.24k stars 1.57k forks source link

Mongodb - class not found in configured namespaces #2075

Closed StefanGlaesser closed 3 years ago

StefanGlaesser commented 8 years ago

Hello,

I'm always getting a

 [Doctrine\Common\Persistence\Mapping\MappingException]
 The class 'AppBundle\Document\User' was not found in the chain configured namespaces

using a fresh install.

This is my current composer.json.

"require": {
        "php": ">=5.5.9",
    "symfony/symfony": "2.8.*",
    "doctrine/orm": "^2.5.4",
    "doctrine/doctrine-bundle": "~1.4",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "~2.0",
    "doctrine/mongodb-odm": "~1.0",
    "doctrine/mongodb-odm-bundle": "~3.0",
    "friendsofsymfony/user-bundle": "~2.0@dev"
},

And some parts of my config.yml

# Mongo-DB Configuration
doctrine_mongodb:
    connections:
        default:
            server: mongodb://localhost:27017
            options: {}
    default_database: portal
    document_managers:
        default:
            auto_mapping: true

# FOS-User Bundle
fos_user:
    db_driver: mongodb # other valid values are 'mongodb', 'couchdb' and 'propel'
    firewall_name: main
    user_class: AppBundle\Document\User

I don't know what todo any more. What's wrong? What else can I do?

zenobius commented 8 years ago

+1 .

fcpauldiaz commented 8 years ago

did you registered the bundle in the app kernel?

StefanGlaesser commented 8 years ago

Yes, i've done everything thats written down in the docs.

zenobius commented 8 years ago

Same config as abovementioned and it throws the same exception. 1.3 works fine, dev-master kills.

DavidFeller commented 8 years ago

+1

SalmaGhareeb commented 8 years ago

+1

geoffrey-brier commented 7 years ago

If this can help, it's working fine for me. My config looks exactly like yours and this is the require section of the composer.json.

"require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.1.*",
        "doctrine/mongodb-odm": "^1.0",
        "doctrine/mongodb-odm-bundle": "^3.0",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "doctrine/data-fixtures": "~1.1.0",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "symfony/polyfill-apcu": "^1.0",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "friendsofsymfony/rest-bundle": "^2.0",
        "jms/serializer-bundle": "^1.1",
        "friendsofsymfony/oauth-server-bundle": "^1.5",
        "friendsofsymfony/user-bundle": "2.0.x-dev",
    }

Did you add the annotation @MongoDB\Document on the User class?

Also, not sure if this is intended but you're using both doctrine ORM and ODM.

damienalexandre commented 7 years ago

We need more informations to help you out:

Thanks