I would like set email to not required on my User entities. How do what ? I've searched in FOSUserBundle/config/ but i don't find any "required" parameter about email.
Following Tib's answer, here is the way I did it. It's working fine :
/**
* User
*
* @ORM\Table(name="user")
* @ORM\Entity
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="email", column=@ORM\Column(type="string", name="email", length=255, unique=false, nullable=true)),
* @ORM\AttributeOverride(name="emailCanonical", column=@ORM\Column(type="string", name="email_canonical", length=255, unique=false, nullable=true))
* })
*/
class User extends BaseUser {
// ...
}
The previous solution is easy to implement and was working fine, but after updating Symfony to version 2.1.8 and without changing anything in my app, generating entities failes throwing a Doctrine mapping exception (Invalid field override ...)
In spite of loosing a lot of time trying to solve that issue, I was just stucked.
Then I finally realized that FOSUserBundle provides lot of features I don't use, but doesn't really fit my needs, which are quite basic.
I need to disable email requirement because my app user management is "software like" : no registration, no email sending, no profil, user and roles managed only by admin, etc...
I was adapting a tool not designed for my needs. So I decided to make my own implementation of Symfony security.
It is a little more work, but it's not very difficult and the result is far better and more flexible than adapting FOSUserBundle. Of course, for a "classic" website or web app, FOSUserBundle is the best.
If you are in this case too, I suggest you to do so. Here is the doc to begin : Security in the Book and Security in the CookBook
I hope this can help you.
Sorry for my poor english, I hope it is intelligible
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With