Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:53:47+00:00 2026-05-27T06:53:47+00:00

I have my UserBundle who extends the FOSUserBundle and works fine. But now, I

  • 0

I have my UserBundle who extends the FOSUserBundle and works fine. But now, I want create multiple users entities with différents properties.
But the problem is when I create my user enttity who extends my main User entity like this :

class User extends BaseUser
{
    protected $id;
    // The main user class who extends FOSUser entity
}

class UserB extends User
{
    //
}

When I do this, I’ve got an error : `

Access level to MyApp\UserBundle\Entity\UserB::$id must be protected (as in class MyApp\UserBundle\Entity\User).

And when I create a protected id in my UserB entity I have this:

PHP Fatal error: Cannot redeclare MyApp\UserBundle\Entity\UserB::$id.

And to finish, I can’t delete the id in my User entity less return a Doctrine error :

[Doctrine\ORM\Mapping\MappingException]
No identifier/primary key specified for Entity ‘MTS\UserBundle\Entity\User’. Every Entity must have an identifier/primary key.

Someone can help me ?

EDIT : Problem solved. My code :

/**
 * MTS\UserBundle\Entity\User
 *
 * @ORM\Entity
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({"userfb" = "UserFB"})
 */
abstract class User extends BaseUser
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string $type
     */
    private $type;
}

/**
 * @ORM\Table()
 * @ORM\Entity()
 */
class UserB extends User
{
    // My variables
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:53:47+00:00Added an answer on May 27, 2026 at 6:53 am

    You problem appears to be the lack of annotation.

    I was able to replicate your ‘Every Entity must have an identifier/primary key’ error message by removing this from my working code:

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    

    The works for me:

     /**
     * @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
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up the UserBundle and everything works fine. Now, instead of modifying
I want to persist a User entity extends FOSUserBundle entity but an error occured
I have 3 entities: Song Artist Genre One song can have multiple genres and
I´ve created my own user Bundle, extending FOSUserBundle. In my UserBundle, I have a
I was recently trying to re-install the fos:userbundle and noticed the docs have changed.
I have this security.yml file. I want to know do i need two firewalls
I'm trying to override FOSUserBundle form Edit profile ; I have created the class
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.