How can I pass two or more parameters by routing annotations?

I have to pass two parameters in the routing annotations, but I get 404 not found

and I don't know why?

<?php
/**
[email protected]("/Product")
*/
class ProductController extends BaseController
{
 /**
 * @Get("/select/{serial:[a-z0-9]}/{id:[0-9]}")
 */
public function selectAction($serial,$id){
...
}
}

and the path that appears in the browser is:

sipv/product?serial=aad123&id=12

the correct path is

sipv/product/aad123/12

but i don't know for configure the route

edited Jun '15

https://docs.phalconphp.com/en/latest/reference/routing.html#parameters-with-names

$router->add(
    "/product/select/{serial:[a-zA-Z0-9_]+}/{id:[0-9]+}",
    array(
        "controller" => "product",
        "action"     => "select"
    )
);


Or getParam

$router->add(
    "/product/([a-zA-Z0-9_]+)/([0-9]+)",
    array(
        "controller" => "product",
        "action"     => "select",
        "serial"       => 1, 
        "id"      => 2
    )
);

Or

$router->add(
    "/product/select/([a-zA-Z0-9_]+)/([0-9]+)",
    array(
        "controller" => "product",
        "action"     => "select",
        "serial"       => 1, 
        "id"      => 2
    )
);

Or 


.... More

When your url looks as follows,

    sipv/product/param = 12

add route,

          $router->add(
    '/sipv/product/:params',
    array(
        'module'     => 'module-name',
        'controller' => 'index',
        'action'     => 'action-name',
        'param'     =>1,
    )
    );

Then in your action

    $this->dispatcher->getParam("param");

Your can go to the following link to read in depth

  https://docs.phalconphp.com/en/latest/reference/routing.html


4.0k

Using annotations, have you tried updating your regular expressions by appending each with a "+" to specify one or more?

You Currently have:

<?php
/**
[email protected]("/Product")
*/
class ProductController extends BaseController
{
 /**
 * @Get("/select/{serial:[a-z0-9]}/{id:[0-9]}")
 */
public function selectAction($serial,$id){
...
}
}

What happens if you update it like so?

<?php
/**
[email protected]("/Product")
*/
class ProductController extends BaseController
{
 /**
 * @Get("/select/{serial:[a-z0-9]+}/{id:[0-9]+}")
 */
public function selectAction($serial,$id){
...
}
}

Notice that I updated Get("/select/{serial:[a-z0-9]+}/{id:[0-9]+}") to include the "+" after each regex



8.5k

why the browser displays the route as well?

sipv/product?serial=aad123&id=12

I put the path manually and can access but I'm sending data via get and appears this route



4.0k

What web server are you running? Nginx, Apache, etc..?

why the browser displays the route as well?

``` sipv/product?serial=aad123&id=12 ```

I put the path manually and can access but I'm sending data via get and appears this route