We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Route aliases ?

Hello,

i just curious ..

so i have multi module app. my router more or less is :

foreach ($application->getModules() as $key => $module) {
                    $router->add('/'.$key.'/:params', array(
                        'module' => $key,
                        'controller' => 'index',
                        'action' => 'index',
                        'params' => 1
                    ))->setName($key);

                    $router->add('/'.$key.'/:controller/:params', array(
                        'module' => $key,
                        'controller' => 1,
                        'action' => 'index',
                        'params' => 2
                    ));

                    $router->add('/'.$key.'/:controller/:action/:params', array(
                        'module' => $key,
                        'controller' => 1,
                        'action' => 2,
                        'params' => 3
                    ));
                }

so now if i call /user/profile/ it goes to module: users and controller profile.

What i want to achive is can I tweak the url in other language ? :), so for example in Bulgarian will be something like /потребител/профил

so calling /потребител/профил (URI) will be the same as /user/profile/

Thanks



34.6k
Accepted
answer

A static route would help

$router->add('/'.$key.'/потребител/профил', array(
    'module' => $key,
    'controller' => 'user',
    'action' => 'profile'
));