symfony - Can't post to symfony2 -


i'm using symfony2 , i'm trying post form controller, controller take request everytime... when i'm using restclient, put post request when use $request->getmethod(), answer :/

the source code simple :

<?php  namespace tc\userbundle\controller;  use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\request; use symfony\component\httpfoundation\response;  class usercontroller extends controller {     /**     * @route("/user/register")     * @method({"post"})     */     public function registeraction(request $request)     {         echo $request->getmethod();         return new response();     } } 

and when add requirements _method: post :

tc_user_register:     path:     /user/register/     defaults: { _controller: tcuserbundle:user:register }     requirements:       _method:  post 

i got : no route found "post /user/register" whatever do, symfony2 take request, idea ?

thanks !

couple of things @xtroyer:

1 if use routing.yml file, requirements: _method not recognised since symfony 2.2, now:

tc_user_register:     path:     /user/register/     defaults: { _controller: tcuserbundle:user:register }     methods:  [post] 

2 if use annotations. @method not recognised if don't mention following use statement in controller:

use sensio\bundle\frameworkextrabundle\configuration\method; 

3 can check route registered following command?

php app/console router:debug | grep tc_user_register 

you should have:

name                       method       scheme      host          path tc_user_register            post                      /user/register/ 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -