1

I am implementing the FOSUser module in my symfony i have created and configure all file as the tutorial.here is my config.yml file for mapping.

 namespace Acme\UserBundle\Entity;

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


 class User extends BaseUser
 {

protected $id;

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

it is showing the following error ..

 MappingException: The class 'Acme\UserBundle\Entity\User' 
was not found in the chain configured namespaces FOS\UserBundle\Entity

here is my config.yml file where i mention the autoloding. still it not working.

      imports:
- { resource: parameters.yml }
- { resource: security.yml }

  framework:
 #esi:             ~
 #translator:      { fallback: %locale% }
 secret:          %secret%
 router:
    resource: "%kernel.root_dir%/config/routing.yml"
    strict_requirements: %kernel.debug%
form:            ~
csrf_protection: ~
validation:      { enable_annotations: true }
templating:
    engines: ['twig']
    #assets_version: SomeVersionScheme
default_locale:  "%locale%"
trusted_proxies: ~
session:         ~
fragments:       ~

# Twig Configuration
twig:
debug:            %kernel.debug%
strict_variables: %kernel.debug%

 # Assetic Configuration
 assetic:
debug:          %kernel.debug%
use_controller: false
bundles:        [ ]
#java: /usr/bin/java
filters:
    cssrewrite: ~
    #closure:
    #    jar: %kernel.root_dir%/Resources/java/compiler.jar
    #yui_css:
    #    jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar

  # Doctrine Configuration
doctrine:
dbal:
    driver:   %database_driver%
    host:     %database_host%
    port:     %database_port%
    dbname:   %database_name%
    user:     %database_user%
    password: %database_password%
    charset:  UTF8
    # if using pdo_sqlite as your database driver, add the path in parameters.yml
    # e.g. database_path: %kernel.root_dir%/data/data.db3
    # path:     %database_path%

orm:
    auto_generate_proxy_classes: %kernel.debug%
    auto_mapping: true

# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host:      %mailer_host%
username:  %mailer_user%
password:  %mailer_password%
spool:     { type: memory }
fos_user:
db_driver: orm 
firewall_name: main
user_class: Acme\UserBundle\Entity\User
j0k
  • 22,600
  • 28
  • 79
  • 90
Viraj.S
  • 305
  • 1
  • 8
  • 18
  • sorry buddy not according to indentation of stack overflow but the important is error i will getting. thanks – Viraj.S Mar 04 '13 at 08:57

4 Answers4

7

Ok, this should be easy. You need to, either enable auto_mapping in your config.yml or to manually specify "AcmeUserBundle: ~" there:

1) with auto_mapping

doctrine:
    orm:
        auto_mapping: true

2) without auto_mapping

doctrine:
    orm:     
        mappings:
            AcmeUserBundle: ~

Notice that if you are having multiple entity managers you won't be able to use auto_mapping feature. Hope this helps!

Jovan Perovic
  • 19,846
  • 5
  • 44
  • 85
  • this is my confing.yml pls look at it – Viraj.S Mar 04 '13 at 08:32
  • i have mention auto loding: true but still there is some error coming – Viraj.S Mar 04 '13 at 08:38
  • Ah so you do have `auto_mapping` enabled. Can you try turning it off and manually adding those bundles? Don't forget to add `FOSUserBundle` as well – Jovan Perovic Mar 04 '13 at 09:45
  • after changing as u tell get new erro "MappingException: Class "Acme\UserBundle\Entity\User" sub class of "FOS\UserBundle\Entity\User" is not a valid entity or mapped super class." – Viraj.S Mar 04 '13 at 12:37
  • I assume you've managed to resolve an issue. Can you write what was the cause? :) – Jovan Perovic Mar 04 '13 at 16:31
  • sorry for late replay. yes the problem is auto_mapping. as soon as i did manually it is working fine now. so thanks once again. – Viraj.S Mar 05 '13 at 06:41
3

It is also can help:

Add into your app/AppKernel.php:

...
new Acme\UserBundle\AcmeUserBundle(),
...
Ilia Shakitko
  • 1,417
  • 2
  • 18
  • 25
  • Yes! I was running into the same problem. I just created a brand new bundle for the game I'm doing (Emperors of the Dynasty), and I located the User class under `namespace Xmontero\Emperors\UserBundle\Entity;` nevertheless following the tutorial, I was concentrated in adding the `FOSUserBundle` into the kernel and I completely forgot to add my `new Xmontero\Emperors\UserBundle\XmonteroEmperorsUserBundle(),` into the `AppKernel.php` - 3 years working with SF2 and forgetting something like this! ow man! not possible!!! – Xavi Montero Apr 23 '14 at 20:30
0

Add the following line to your app/AppKernel.php file's bundle array:

new FOS\UserBundle\FOSUserBundle()

This is to register that namespace for Symfony.

tolgap
  • 9,629
  • 10
  • 51
  • 65
0

solucion for me:

change in ../Entity/User.php

namespace Acme\UserBundle\Entity; with namespace Acme\Bundle\UserBundle\Entity;

and in app/config.yml change

user_class: Acme\UserBundle\Entity\User with
user_class: Acme\Bundle\UserBundle\Entity\User

Regards, Amic

amic
  • 85
  • 7