Baby Webmaster
Baby Webmaster

Reputation: 335

Symfony\Component\HttpKernel\Exception\ NotFoundHttpException

I am following the openclassrooms tutorial on symfony. I am now currently at the chapter "Les controleurs avec Symfony".

I try to open http://localhost/Symfony/web/app_dev.php and get this error

NotFoundHttpException

I suspect the error to come from AdvertController.php. But I compared it with the given code at the tutorial. And it is exactly the same. I tried then to delete the cache but it does not function. I will open another question for that.

Here is the AdvertController.php code:

<?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."."

          );

      }


}



?>

If you would like me to post other parts of code, please let me know. I have no idea, where to look at.

Thank you very much!

Upvotes: 2

Views: 6923

Answers (2)

Lerminou
Lerminou

Reputation: 199

You can try to dump your routes with the command php bin/console debug:router or app/console for symfony <3.0 to see if there is a route your your desired path. If you have the prefix /platform, your paths inside your controller are now /platform/path instead of /path.

You need a default route for your root path.

Upvotes: 2

al37350
al37350

Reputation: 139

The message error is very explicit, there are not routes for "/". Try to verify your routing.yml

Upvotes: 0

Related Questions