Phalcon\Mvc\Router()

<?php
$router->add("/admin/([a-zA-Z0-9_-]+)[/]?([a-zA-Z0-9_]+)?[/]?(/.*)*", array(
        'namespace' => 'App\Controllers\Admin',
        'controller' => 1,
        'action' => 2,
        'params' => 3
));

//when the action pattern matches is empty why the action value is 2, not the 'index' on linux


10.8k

Because it reads

'action' => 2,

as a default action. Add that route:

$router->add("/admin/:controller", array(
    'namespace' => 'App\Controllers\Admin',
    'controller' => 1,
    'action' => 'index'
));

Also, your route is the same as

$router->add("/admin/:controller/:action/:params", array(
    'namespace' => 'App\Controllers\Admin',
    'controller' => 1,
    'action' => 2,
    'params' => 3
));

Why not use the more simple syntax?