I am using Symfony 4.4 and trying to upload an image. But while creating schemas I am getting an Annotation error.
[Semantical Error] The annotation “@SymfonyComponentValidatorConstraintsImageImage” in property AppEntityStudent::$photo was never imported. Did you maybe forget to add a “use” statement for this annotation?
Attaching the code snippets below, please say what is the mistake I made.
use SymfonyComponentValidatorConstraints as Assert;
/** * @AssertNotBlank(message="Please, upload the photo.") * @AssertFile(mimeTypes={ "image/png", "image/jpeg" }) */ private $photo;
=====================
Advertisement
Answer
It looks like you forgot to add use SymfonyComponentValidatorConstraints as Assert;
to the top of the file.
According to the error message and the documentation for NoBlank, that line should fix your issue.