我正在关注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