D
D
dllweb2015-05-08 21:36:05
symfony
dllweb, 2015-05-08 21:36:05

Why don't default parameters work in symfony2 routing?

The manuals describe that if, after inclusion in the defaults array after the specified action, set the default value of its parameter as here, then the parameter will correspond to the value specified by default, I give my example, which is identical in mana

manager_cpanel:
       pattern: /manager/cpanel/{p}
       defaults: { _controller: NiceBundle:manager\Manager:cpanel, p: "start" }

here is the action code
/**
     * @Route("/cpanel/{p}")
     * @Template()
     */
    public function cpanelAction($p=null, Request $r){
    return array("p"=>$p);
     }

Instead of my route not becoming /cpanel/start,
I just get an exception
No route found for "GET /manager/cpanel/"
on a piece of Url in the form /manager/, don't pay attention.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BoShurik, 2015-05-08
@dllweb

/**
     * @Route("/cpanel/{p}", defaults={"p" = "start"})
     * @Template()
     */
    public function cpanelAction($p=null, Request $r){
        return array("p"=>$p);
    }

Well, Alex T. is right. You describe routes in yml, although, in fact, routes are imported from annotations

A
Alex, 2015-05-08
@shoomyst

Horror, horror, horror :)
You already decide where to set the route - in annotations or in configs)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question