Creating a new user with FOSUserBundle fails
Fixed!
I had a custom constructor method in my User entity. There I had forgotten to call the parent's constructor with parent::__construct();
Maybe it help someone. You can see this error when use bcrypt encoder.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null
To solve this issue just add mapping override for salt attribute in your User class (make it nullable)
use FOS\UserBundle\Model\User as BaseUser;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity * @ORM\AttributeOverrides({ * @ORM\AttributeOverride( * name="salt", * column=@ORM\Column(name="salt", type="string", nullable=true) * ) * }) */class User extends BaseUser { ...}
OR: don't forget update your schema. If error happend after composer update!
bin/console doctrine:schema:update --force