我在Symfony2中安裝了一個電子郵件驗證器,用於通訊表格。當地一切正常,但如果我上傳整個文件夾到我的虛擬主機,我收到以下錯誤信息:Symfony2約束條件未找到電子郵件
Fatal error: Class 'Symfony\Component\Validator\Constraints\email' not found in /home/donacico/public_html/spendu/donaci14/vendor/symfony/symfony/src/Symfony/Component/Validator/Mapping/Loader/AbstractLoader.php on line 64
我的驗證陽明看起來是這樣的:
# src/Dbe/DonaciBundle/Resources/config/validation.yml
Dbe\DonaciBundle\Entity\Newsletter:
properties:
email:
- email:
message: The email "{{ value }}" is not a valid email.
checkMX: true
Dbe\DonaciBundle\Entity\Contact:
properties:
email:
- email:
message: The email "{{ value }}" is not a valid email.
checkMX: true
這裏是的動作創建控制器:
/**
* Creates a new Newsletter entity.
*
*/
public function createAction(Request $request) {
$entity = new Newsletter();
$form = $this -> createCreateForm($entity);
$form -> handleRequest($request);
if ($form -> isValid()) {
$em = $this -> getDoctrine() -> getManager();
$em -> persist($entity);
$em -> flush();
$this -> get('session') -> getFlashBag() -> add('newsletterSubscribed', 'Thank you for subscribing!');
}
return $this -> render('DbeDonaciBundle:UnderConstruction:index.html.twig', array('entity' => $entity, 'form' => $form -> createView(),));
}
另外在config.yml文件我啓用了驗證:
framework:
validation: { enable_annotations: true }
任何想法可能會導致此錯誤?
請記住,雖然Windows的路徑和PHP標識符(類名)是區分insensitivie,Linux的文件路徑不。將'email'改爲'Email',你應該沒問題。 – Crozin