Reputation: 3938
I have the weirdest problem. Everything was doing just fine and suddenly symfony shows
"No route found for "GET /"
So i checked router and..none of the routes from my controller were in there.
So i added routing to the routing.yml and right now it throws
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "_edit_user" as such route does not exist.") in C:\xampp\htdocs\zadanie\src\Cart\Bundle/Resources/views/User/index.html.twig at line 2
EVEN THOUGH the action which name is "_edit_user" is right under the one that is being called from routing.
What the hell is happening?
EDIT: here is what router:debug says:
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_purge ANY ANY ANY /_profiler/purge
_profiler_info ANY ANY ANY /_profiler/info/{about}
_profiler_import ANY ANY ANY /_profiler/import
_profiler_export ANY ANY ANY /_profiler/export/{token}.txt
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
_configurator_home ANY ANY ANY /_configurator/
_configurator_step ANY ANY ANY /_configurator/step/{index}
_configurator_final ANY ANY ANY /_configurator/final
blog_show ANY ANY ANY /
and blog_show is the one I added in the routing.yml..
Upvotes: 2
Views: 6631
Reputation: 105916
Symfony2 doesn't auto-map action methods to route names. If you need an action method to be routable, you have to specify that explicitly.
I personally like using annotations for routing, so if you want to do the same, then first add this to app/config/routing.yml
YourBundle:
resource: "@YourBundle/Controller/"
type: annotation
prefix: /
Then add your routing information to your controllers. To use the default controller as an example:
src/Your/Bundle/Controller/DefaultController.php
<?php
namespace Your\Bundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class DefaultController extends Controller
{
/**
* @Route("desired/edit_user/uri", name="_edit_user")
*/
public function _edit_userAction()
{
/* ... */
}
}
Upvotes: 3