Sadly, this isn’t really documented (at time of writing).
Adding new protected variables to your User.php entity will not actually create database entries when you try to do a doctrine:schema:update.
While one still needs to have the protected variables in this entity class, along with getters and setters, the actual creation work is within UserBundle/Resources/config/doctrine/User.orm.xml
Here is an example for adding a foreign key:
5 thoughts on “Adding extra fields to FOSUserBundle / SonataUserBundle”
A year later it’s still not documented.
Thanks man 🙂
Thanx, I couldn’t find this info anywhere… except here 🙂
2012 – 2017, 5 years later, still not documented?????
Thanks, Man ! You save my life
7 years later, still not documented 🙂 Thank you so much for your post, that helped me a lot as well.
I thought my comment might be helpful to somebody as well, for them who are interested in not only having new fields created in DB, but also getters and setters to be generated in the Entity class as well.
I’m using Symfony 4 and SonataUserBundle.
1. Add a new field to the xml, like:
2. Add new property to the Entity:
use Doctrine\ORM\Mapping as ORM;
* @ORM\Column(type=”string”, length=65)
3. Run command bin/console make:entity –regenerate and give the namespace like “App\Application\Sonata\UserBundle\Entity”
no change: src/Application/Sonata/UserBundle/Entity/Group.php