我正在關注symfony上的openclassrooms教程。我現在正在閱讀「Symfony的控制者」一章。Symfony Component Routing Exception InvalidParameterException
我嘗試打開http://localhost/Symfony/web/app_dev.php/platform,我得到這個錯誤
這裏是AdvertController.php代碼:
<?php
//src/Neo/PlatformBundle/Controller/AdvertController.php
namespace Neo\PlatformBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
//use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class AdvertController extends Controller
{
public function indexAction()
{
$url= $this->get('router')->generate(
'neo_platform_view', //first argument : path name
array('id' => 5)
);
return new Response("The url of the announcement is:".$url);
}
public function viewAction($id)
{
return new Response("Desplay of the announcment with id:".$id);
}
public function viewSlugAction($slug, $year, $_format)
{
return new Response(
"We could desplay the announcment conrresponding the the slug '".$slug."', created in ".$year." and with the format ".$_format."."
);
}
}
?>
我不明白的錯誤意味着什麼,不知道如何解決它。 謝謝你的幫助!
你能從你的routing.yml中顯示'neo_platform_view'的路由定義嗎? – Joe
neo_platform_view: 路徑:/廣告/ {ID} 默認: _controller:NeoPlatformBundle:廣告:鑑於 要求: ID:\ ID + –
你或許應該開始另一個之前完成一個問題。我可能會補充說,如果你在教程中遇到這麼多麻煩,那麼你可能會嘗試其他的東西。像文檔一樣?當你添加諸如路由定義之類的東西時更新你的問題。評論格式不好。 – Cerad