Why this did not work for the OP, but it worked for others (e.g. @gregor):
When creating slug, your first instinct is to create the slug property with this column configuration:
.. @ORM\Column(unique=true, nullable=false) private $slug; ..
When you run app/console doctrine:schema:update and this will lead to 2 sql statements:
ALTER TABLE ... ADD slug ... NOT NULL CREATE UNIQUE INDEX...`.
By default, the slug column will be filled with the value '' (empty row), which will lead to the error of the 2nd statement with the error ( Duplicate entry '' ). You now have two options:
Option A: Ignore Second Operator Failure
If you ignore the error and later try to create bullets manually using the documented method $entity->setSlug(null) , everything will work. This would work because using $entity->setSlug(null) , you would let Doctrine know that the slug property has been changed (from '' to null ), and this in turn will cause internal $uow->propertyChanged() and $uow->scheduleForUpdate() (thanks to @Sebastian Rad for his example). The Sluggable extension Sluggable also notice this change and will regenerate the slug. Now that all the bullets are unique, the next time you run app/console doc:schema:update it will be able to create an index on slug and your circuit will be fully synchronized.
Choice B: Change the slug field to nullable After you notice an error, your instinct should mark the slug field as nullable , so creating the index will succeed:
.. @ORM\Column(unique=true, nullable=true) private $slug; ..
This will cause the slug column to be null as the default value. Now, when you try to use the documented approach $entity->setSlug(null) , it will not work (just like the OP published). This is because when the $entity->slug property is already null . Thus, when you use $entity->setSlug(null) , Doctrine does not detect any changes, and therefore the Sluggable regeneration behavior never fires. To trigger the changes, there were two answers:
hack by adding space to source properties slug $entity -> setTitre($titre." "); (but this will result in extra space that you have to crop after)
@Sebastian Radu's approach, where he shows how to directly tell the doctrine that the field has been changed (I personally prefer this and wonder why it was unfairly underestimated)
Hope this helps you better understand the inner workings of the Doctrine and extensions.