我正在关注symfony上的openclassrooms教程。我现在正在阅读“Symfony的控制者”一章。Symfony Component HttpKernel Exception NotFoundHttpException
我尝试打开http://localhost/Symfony/web/app_dev.php和得到这个错误
我怀疑错误来自AdvertController.php。 但我将它与本教程中的给定代码进行了比较。它完全一样。我试图然后删除缓存但它不起作用。我会为此打开另一个问题。
这里是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."."
);
}
}
?>
如果你想我张贴的代码其他地方,请让我知道。 我不知道,在哪里看。
非常感谢!
您好!感谢您的评论。我实际上检查了app/config/routing.yml:我写了:prefix:/ platform因为这个原因,认为Rersources/config/routing.yml只包含路径:/ {page}而不是路径:/ {page} 。我在教程中完全一样。我怎么能解决这个问题?非常感谢! –