symfony - In Symfony2, how to use Multiple Routes in Default Controller -


i've been trying map multiple routes default controller, , doesn't seem working expected.

i'm using annotations in controller:

/**  * @route("/", name="index_controller");  * @template("seoslinkybundle:default:index.html.twig");  */  public indexaction() {} 

but want this:

/**  * @route("/", name="index_controller");  * @route("/{timeoption}", name="index_controller");  * @template("seoslinkybundle:default:index.html.twig");  */  public indexaction($timeoption = "today") {    echo $today;    exit;  } 

that works, , if go to:

http://myapp/hello

the controller echoes "hello"

but if go to

http://myapp/

the controller should echo "today"

but instead i'm getting error:

cannot import resource "/usr/share/www/myapp/src/myappbundle/controller/" "/usr/share/www/myapp/app/config/routing.yml".

these contents of routing.yml

my_app:     resource: "@myappbundle/controller/"     type:     annotation     prefix:   / imag_ldap:     resource: "@imagldapbundle/resources/config/routing.yml" 

any appreciated!

my guess because have 2 routes same name wrong.

you should try :

/**  * @route("/", name="index_controller");  * @route("/{timeoption}", name="index_controller_timeoption");  * @template("seoslinkybundle:default:index.html.twig");  */  public indexaction($timeoption = "today")   {      echo $today;      exit;  } 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -