Symfony2 routing annotation leads to NotFoundHttpException 1 linked Exception: ResourceNotFoundException

StackOverflow https://stackoverflow.com/questions/21840415

  •  12-10-2022
  •  | 
  •  

Question

I get the following exception when trying to access //localhost/dga/web/app_dev.php/gerer/sami.

No route found for "GET /gerer/sami" 404 Not Found - NotFoundHttpException 1 linked Exception:

ResourceNotFoundException »

src/app/config/routing.yml

gestion_utilisateur:
    resource: "@GestionUtilisateurBundle/Controller"
    type:     annotation
    prefix:   /

src/Application/EncaissementBundle/Controller/GererController.php

namespace Application\EncaissementBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

class DefaultController extends Controller 
{
    /**
     * @Route("/gerer/{name}", name="application_encaissement_gere")
     * @Template()
     */
    public function indexAction($name) 
    {
        return $this->render(
            'ApplicationEncaissementBundle:Gerer:index.html.twig',
            array('name' => $name)
        );
     }
Was it helpful?

Solution

As I see, the action indexAction you defined is in the controller DefaultController. But the response you are send is to the a twig file of another controler which shall be GererController.

Make some checks on the controllers name & the twig resource you are calling (which is 'ApplicationEncaissementBundle:Gerer:index.html.twig').

How many controllers you have?

Best,

OTHER TIPS

it works!!I just configured my apache server

sudo gedit /etc/apache2/apache2.conf

And to comment this /home/user/NetBeansProjects in the file apache2.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>
<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
#<Directory /home/user/NetBeansProjects>
#  Options Indexes FollowSymLinks MultiViews
#  AllowOverride All
#  Order allow,deny
#  Allow from all
#</Directory>

:) amine thank you for your help

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top