我正在学习关于symfony的开放教室教程。我现在在"Les controleurs avec Symfony“一章。
我尝试打开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."."
);
}
}
?>我不明白这个错误意味着什么,也不知道如何修正它。谢谢你的帮助!
发布于 2017-09-15 13:04:47
neo_platform_view:
path: /advert/{id}
defaults:
_controller: NeoPlatformBundle:Advert:view
requirements:
id: \d+将\id+更改为\d+ --这将修复它。如果只允许使用数字,则\d+是正确的条件。
https://symfony.com/doc/current/routing/requirements.html用于进一步阅读需求。
https://stackoverflow.com/questions/46240068
复制相似问题