0

im not sure what ive done wrong here.

I am following the instruction on how to install the fos bundle and have come across a problem.

I am getting the following error:

PHP Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class RS\Entity\User is not a valid entity or mapped super class.' in PATH\vendor\doctrine\lib\Doctrine\ORM\Mapping\MappingException.php:142

My user class is in /src/RS/Entity/User.php

And i have'RS' => __DIR__.'/../vendor/reportsuite/src'in app/autoload.php

The class is

<?php
// /src/RS/Entity/User.php

namespace RS\Entity;

use FOS\UserBundle\Entity\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
    }
}

As far as i can tell this is a mapped entity, unless im missing something?

Ive also tried creating the entity in by bundle and another bundle like Acme/UserBundle/Entity/User.php

# Doctrine Configuration
doctrine:
    dbal:
        default_connection:       default
        connections:
            default:
                dbname:           axpdb
                user:             %database_user%
                password:         %database_password%
                host:             %database_host%
                port:             %database_port%
                charset:          UTF8
            reportsuite:
                dbname:           reportsuite
                user:             %database_user%
                password:         %database_password%
                host:             %database_host%
                port:             %database_port%
                charset:          UTF8
    orm:
        entity_managers:
            default:
                connection:       default
                mappings:
                    ReportSuiteMainMenuBundle: ~
            reportsuite:
                connection:       reportsuite
                mappings:


# Security
jms_security_extra:
    secure_controllers:  true
    secure_all_services: false

# FOS User Config
#fos_user:
#    db_driver: orm
#    firewall_name: main
#    user_class: RS\Entity\User
#    model_manager_name: reportsuite

I have 2 databases that I need to access and I have commented out the fos stuff so i can continue working.

Juan Sosa
  • 5,262
  • 1
  • 35
  • 41
Lee
  • 1,096
  • 2
  • 20
  • 33
  • Could you paste the `doctrine:` entry from your `config.yml`? I suspect you have not configured your mapping correctly. (see http://stackoverflow.com/questions/8636144/integrating-bundles-related-doctrine-2-entities-in-symfony-2-and-coupling/8637640#8637640) – Kris Wallsmith Jan 02 '12 at 15:07
  • Is there a reason why you are not using the default bundle structure? – Alessandro Desantis Jan 03 '12 at 11:33
  • The project is dynamic where customers can drag/drop custom modules in and out of the system. So I put the code in RS/ that is global to all the modules. Unless this is the wrong approach? I'm used to working with Zend Framework. – Lee Jan 03 '12 at 15:48

3 Answers3

0

Run

touch Entity/*

and you are OK.

Kjuly
  • 34,476
  • 22
  • 104
  • 118
Peyman
  • 1
0

Did You checkd a namespace ?

I think it should be:

namespace Namespace\YourBundle\Entity

You can use entites from all of Your bundles.

Pawel
  • 1,672
  • 2
  • 18
  • 24
-1

Had this problem - don't forget the annotation * @ORM\Entity like below:

/**
 * Powma\ServiceBundle\Entity\User
 *
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
Mike
  • 3,087
  • 3
  • 17
  • 13