Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

时间:2017-09-15 10:55:39

标签: symfony

我正在关注symfony的openclassrooms教程。我现在正处于“Les controleurs avec Symfony”这一章。

我尝试打开http://localhost/Symfony/web/app_dev.php并收到此错误

NotFoundHttpException

我怀疑来自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."."

          );

      }


}



?>

如果您希望我发布其他代码部分,请告诉我们。 我不知道,在哪里看。

非常感谢!

2 个答案:

答案 0 :(得分:1)

您可以尝试使用php bin/console debug:routerapp/console命令转储路径,以获取symfony&lt; 3.0,以查看是否有您所需路径的路线。 如果你有前缀/平台,你的控制器内的路径现在是/ platform / path而不是/ path。

您的根路径需要默认路由。

答案 1 :(得分:0)

消息错误非常明确,没有&#34; /&#34;的路由。尝试验证你的routing.yml

相关问题