的Symfony對ParamConverter手冊裏有這個例子:Symfony2 - 如何在控制器中使用@Entity標註?
/**
* @Route("/blog/{post_id}")
* @Entity("post", expr="repository.find(post_id)")
*/
public function showAction(Post $post)
{
}
但使用@Entity標註給了我這個錯誤。
The annotation "@Entity" in method AppBundle\Controller\CurrencyController::currencyAction() was never imported. Did you maybe forget to add a "use" statement for this annotation?
顯然,我需要使用一個命名空間,但哪一個?請幫忙。
你需要做什麼錯誤消息說 - 導入實體。您忘記在腳本的頂部添加「使用」語句。 –
對,但是究竟是哪一個?這是個問題。 SensioFrameworkExtraBundle沒有@Entity註釋(至少不在Symfony2中),但手冊建議使用它。 –