Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed
I have found the solution : I had to implement Serializable
interface like this : official doc
Little extra precision in DOZ words :
It's better to implement \Serializable
in your Image (or File, or @Vich\Uploadable) Entity instead of implement \Serializable
on User Entity because you probably break login in this case.
If you are using VichUploader like me don't add \Serializable
on your User Entity and add it on your @Vich\Uploadable
(Image or File) Entity and add the two methods :
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->image,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->image,
) = unserialize($serialized, array('allowed_classes' => false));
}