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 8629605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:51:03+00:00 2026-06-12T08:51:03+00:00

I use FosUserBundle and SonataUserBundle for my Symfony2 project. I get confused now. I

  • 0

I use FosUserBundle and SonataUserBundle for my Symfony2 project.

I get confused now. I want to add fields for the entity User but it’s not working. There is no update for the schema for example.

Here is my config :

AppKernel:
...
new FOS\UserBundle\FOSUserBundle(),
new Sonata\UserBundle\SonataUserBundle(),
new Application\Sonata\UserBundle\ApplicationSonataUserBundle('FOSUserBundle')


config.yml:
...
# FOSUserBundle Configuration
fos_user:
    db_driver:     orm                        # BDD type
    firewall_name: main                       # firewall name
    user_class:    Application\Sonata\UserBundle\Entity\User # entity class defined

And the User entity with added fields, in app/Application/Sonata/userBundle/Entity/

namespace Application\Sonata\UserBundle\Entity;

use Sonata\UserBundle\Entity\BaseUser as BaseUser;

/**
 * This file has been generated by the Sonata EasyExtends bundle ( http://sonata-    project.org/easy-extends )
 *
 * References :
 *   working with object : http://www.doctrine-project.org/projects/orm/2.0        /docs/reference/working-with-objects/en
 *
 * @author <yourname> <youremail>
 */
class User extends BaseUser
{

    /**
     * @var integer $id
     */
    protected $id;

    /**
     * @var string
     */
    protected $institution;

    /**
     * @var string
     */
    protected $department;

    /**
     * @var string
     */
    protected $city;

    /**
     * @var string
     */
    protected $country;

    /**
     * Get id
     *
     * @return integer $id
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return string
     */
    public function getInstitution()
    {
        return $this->institution;
    }

    /**
     * @return string
     */
    public function getDepartment()
    {
        return $this->department;
    }

    /**
     * @return string
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * @return string
     */
    public function getCountry()
    {
        return $this->country;
    }
}

In my database, table fos_user_user seems to be the table with user saved data.

Added fields (country, city…) are not created when calling “php app/console doctrine:schema:update –force”. How to add fields to the user entity ? I’m lost in fosuserbundle and sonatauserbundle….

  • 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-06-12T08:51:04+00:00Added an answer on June 12, 2026 at 8:51 am

    In fact, it appear that the way i use fos and sonata user bundles force me to use XML definition. So for example adding a field called “city” you have to add these lines :

    User.php (in /app/Application/Sonata/UserBundle/Entity/) :

    protected $city;
    

    User.orm.xml (in /app/Application/Sonata/UserBundle/Ressource/config/doctrine/) :

    <field name="city" column="city" type="text"/>
    

    Maybe putting this in the documentation of the bundles would be interesting for newbies 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the FOSUserBundle and in my User class I want two things: a
I have a Symfony2 project with user management (FOsUserbundle & Sonata bundles). In some
I use the FOSUserBundle and I want to override his registerAction controller. I read
I cant get the form_widget (from mopabootstrapbundle) to use the translation (from FOSUserBundle) to
I've just imported the FOSUserBundle for the first time into a symfony2 project and
I am using SonataUserBundle for extending user managing functionality. Also i use this bundle
I just upgrade my Symfony 2.0.12 project to 2.1. I also installed FosUserBundle, but
Hy guys, I decided to use FOSUserBundle for handling user authentication in my application.
I use symfony 2 with FOSuserbundle. Creat action for lock user with code: $repository
I have validation constraints defined in my validation.yml for my User entity, but none

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.