There was an error with the cache: Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed - /var/www/utip-symfony/vendor/phpfastcache/phpfastcache/lib/Phpfastcache/Core/Pool/DriverBaseTrait.php code example

Example 1: Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed

For Vich Uploader,
you need to use implements Serialize

  use Serializable;

  
  Class EntityName implements Serialize
{
  
  //code here
  
      public function serialize()
    {
        return serialize($this->getId());
    }

    public function unserialize($serialized)
    {
        $this->id = unserialize($serialized);
    }
}

It works for me.

Example 2: Serialization of 'Symfony\Component\HttpFoundation\File\File' is not allowed

For Vich Uploader
you need to use implements and public function serializable/unserializable.

  class NameEntity implements Serializable
{
  
  //code here 
  
  public function serialize()
    {
        return serialize($this->getId());
    }

    public function unserialize($serialized)
    {
        $this->id = unserialize($serialized);
    }
}

It works for me.

Tags:

Php Example