PM-Riabel PM-Riabel - 3 months ago 26
PHP Question

Symfony Routing: No route found for "GET /user/add"

I am developing a simple User App to practice Symfony (3.1.3).
I created a new Bundle,

//pie10-api/api/src/PIE10Bundle/Controller/BackendUmController.php

<?php

namespace PIE10Bundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;

class BackendUmController extends Controller
{
/**
* @Route("/user")
*/
public function indexAction()
{
// nothing for now
}

/**
* @Route("/user/add")
*/
public function adduserAction()
{
return $this->render('PIE10Bundle:users:layout_new_user.html.twig');
}
}


and created a test view on,

//pie10-api/api/src/PIE10Bundle/Resources/views/users/layout_new_user.html.twig

When I try to access that using the following URL,

http://localhost/app/web/app_dev.php/user/add

it gives the following 404 Error

No route found for "GET /user/add"

and I tried some on-line solutions like clear cache... but could not solve this and I need someones hand to get rid this error.

And please let me know if any other information needed related to my development.

Answer

Did you have add in app/config/routing.yml

app:
    resource: "@PIE10Bundle/Controller/"
    type:     annotation

You have to check this (name="foo").

/**
 * @Route("/", name="homepage")
 */
public function adduserAction(Request $request)
{
    // replace this example code with whatever you need
}