ことができませんでした私はSymfony4アプリケーションに取り組んでいると私はこのエラーを持っている:Symfony4:注釈が存在しない場合、または自動ロード(symfonyのコンポーネントバリ制約)
[意味論的エラー]プロパティApp \ Entity \ Product :: $ brochureの "@Symfony \ Component \ Validator \ Constraints \ NotBlank"アノテーションが存在しないか、または自動ロードできませんでした。ここで
はProduct
クラスです:
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
*/
class Product
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
*/
private $name;
/**
* @ORM\Column(type="decimal", scale=2, nullable=true)
*/
private $price;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\Column(type="string")
*
* @Assert\NotBlank(message="Please, upload the product brochure as a PDF file.")
* @Assert\File(mimeTypes={ "application/pdf" })
*/
private $brochure;
public function getBrochure()
{
return $this->brochure;
}
public function setBrochure($brochure)
{
$this->brochure = $brochure;
return $this;
}
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
// ... getters & setters for price & description
public function setPrice($price)
{
$this->price = $price;
}
public function setDescription($description)
{
$this->description = $description;
}
}
注釈 "@Symfony \コンポーネント\バリ\制約ファイル\" もエラーになります。 多分、私はSymfonyで何かを設定するのを忘れました、私は分かりません。
提案がありますか?
どこに電話しますか?いつあなたはそれを必要としますか?それはあなたのコードに '\ namespace \ of \ Product'の問題がありませんか? – Zyigh
実行時エラー私は、データを置いたり投稿したりするときに起こると思います。パンフレットの値を渡して、空白でないことを確認してください。 –
データベースとコマンドを 'php bin/console 'で同期させると、 doctrine:migrations:diff' – simslay