Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Parameters in Router Annotations


I have a problem with parameters in \Phalcon\Mvc\Router\Annotations. I want change my long routing file to annotations mechanism which is awesome. Before I have something like this:

$router->add('/example/all/(\d{4})/(\d{2})([/]?)', array(
    'controller' => 'example',
    'action' => 'index',
    'year' => 1,
    'month' => 2

I change this rule to annotation in indexAction of ExampleController:

     * @Route("/all/(year:\d{4})/(month:\d{2})", name="example-name")
    public function indexAction($year = null, $month = null)
        if (is_null($year) || is_null($month)) {
            $year = date('Y');
            $month = date('m');


        $this->view->year = $year;
        $this->view->month = $month;

In view I use named route:

{{ url(['for': 'example-name', 'year': year, 'month': month]) }}

Before I got this url:

After change to annotations I got:

@Phalcon is it a bug or am I doing something wrong?

//cc @Baryshev @Dreamsxin


My fault, I used round brackets () instead of braces {} for defining parameters. The annotation should be looks:

     * @Route("/all/{year:\d{4}}/{month:\d{2}}", name="example-name")