We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

How I can make this route rule works?

$router->add('/Device/{mac:(?:[a-f0-9]{2}:){5}(?:[a-f0-9]{2})}', ['controller' => 'Device', 'action' => 'index']);

I try to print $this->dispatcher->getPrams(); I get Array(mac => 1).


What exactly doesn't work? You can access it by

    public function indexAction() {
        $params = $this->dispatcher->getPrams();
        $mac = $params['mac']

But if you want to that params to be like 0 => .. , 1 => .. then your code shoould be

            'controller' => 'Device',
            'action' => 'index',
            'params' => 1

Correct me if I'm wrong!!

public function indexAction() {
        $params = $this->dispatcher->getPrams();

the output is:

Array ( [mac] => 1 ), so what is wrong?

Have you tried running your pattern against a URL you think it should match against? Not as a route - just write some test code to see if your pattern works.