2013-04-08 19 views
3

我收到此錯誤什麼是語義錯誤的Symfony2

[Doctrine\Common\Annotations\AnnotationException]        
[Semantical Error] Couldn't find constant CJBusinessBundle:PO:new, method 
CJ\BusinessBundle\Controller\ProductController::createAction().  

我的註釋部分

/** 
* Creates a new Product entity. 
* 
* @Route("/", name="product_create") 
* @Method("POST") 
* @Template(CJBusinessBundle:PO:new.html.twig) 
*/ 

我不明白,這將是本

+2

你忘了引號 – Touki 2013-04-08 08:16:25

回答

6

問題總結模板用引號定義。
否則,當註釋被查找時,它正在尋找一個PHP常量,這就是您所看到的錯誤,因爲沒有該名稱的常量。

/** 
* Creates a new Product entity. 
* 
* @Route("/", name="product_create") 
* @Method("POST") 
* @Template("CJBusinessBundle:PO:new.html.twig") 
*/ 
+1

隨着'.html.twig'工作 – Erioch 2013-04-08 08:18:57

+1

您需要添加'.html.twig'或會發生一個「找不到模板」的錯誤 – Touki 2013-04-08 08:19:22

+0

是啊,我的錯誤後,改變了2.0,將會更新。 – catchamonkey 2013-04-08 08:30:04