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

Routing russian character

{name:[\x7F-\xFF]+} {name:[а-я]+/u} {name:[а-я]+#u} doesn't work... How I can use russian in route?

Have you tried to skip regular expression in the route?

If you need some filtering you can read "Using conversors" here https://docs.phalcon.io/en/latest/reference/routing.html

On all websites/applications i've worked i always "slugalized" cyrilic letters since some browsers encode them and the urls become huge and ugly. For example София = sofia, Пловдив = plovdiv

edited Feb '16

Nikolay Mihaylov this not my. example, how you think conversion "ь" "э" "ё" and other? and know each other user how work conversion? You openion - crazy. P.S. wiki have russian in adress - all normal for this use.

So Have you tried to skip regular expression in the route? and see if this works for you?

About slugalization: i just shared my opinion.


Nope, this first i tried. Need hex in regular but and don't understand what wrong and doesn't work...

edited Feb '16

I'm almost 100% sure that phalcon uses normal regular expression for the routes. So for russian (cyrilic) you could try with \p{Cyrillic}

More info here: https://itworkarounds.blogspot.bg/2011/08/validating-cyrillic-utf8-alphanumeric.html


good. try your recommendation yourself. flood only flood. Don't know how work - don't write. I know how use google.

edited Feb '16

Tested this scenario and it works:

// Route
$router->add('/{slug}', 'Test::view')->setName('page');   

// Controller
class TestController extends BaseController
    public function viewAction()
        // URL: website.com/ьэё-асдявъ
        // Outputs: ьэё-асдявъ

        // URL: website.com/аз-съм-невъзпитан-руснак 
        // Outputs: аз-съм-невъзпитан-руснак 

        // URL: website.com/йцукенгшщзфывапролдячсмить
        // Outputs: йцукенгшщзфывапролдячсмить

Perhaps there is problem in your app? Or try to give more details about your problem?

Just trying to help, dont need to be so rude :)

edited Feb '16
  1. where i ask about "slug"?
  2. slug conversion (space) _ in -. This is for me inportant negative.
  3. need filter in route, before call controller.

  4. read source https://github.com/phalcon/cphalcon/blob/phalcon-v2.0.9/phalcon/mvc/router/route.zep.
  5. read doc https://docs.phalcon.io/en/latest/reference/routing.html
  6. and find 3 defferent.
  7. after all where use phalcon normal pcre and why i must use "slug"?


i think i am gonna open a pull request so people can be ignored ...

edited Feb '16

What version for Phalcon do you use?

I have Phalcon 2.1.x and everything works fine.

use Phalcon\Mvc\Router\Annotations as Router;

$router = new Router(false);
$router->addModuleResource('frontend', 'Evc\Frontend\Controllers\Russian',    '/p/русский');

return $router;


namespace Evc\Frontend\Controllers;

 * @RoutePrefix("/p/русский")

class RussianController extends ControllerBase
     * @Get("/мальчик/{name:[а-я]+}")
    public function russianAction($name)
              protected '_matchedRoute' => 
                  protected '_pattern' => string '/p/русский/мальчик/{name:[а-я]+}' (length=48)
                  protected '_compiledPattern' => string '#^/p/русский/мальчик/([а-я]+)$#u' (length=48)
                  protected '_paths' => 
                    array (size=5)
                      'module' => string 'frontend' (length=8)
                      'namespace' => string 'Evc\Frontend\Controllers' (length=24)
                      'controller' => string 'russian' (length=7)
                      'action' => string 'russian' (length=7)
                      'name' => int 1
                  protected '_methods' => string 'GET' (length=3)
                  protected '_hostname' => null
                  protected '_converters' => null
                  protected '_id' => int 0
                  protected '_name' => null
                  protected '_beforeMatch' => null
                  protected '_match' => null
                  protected '_group' => null

So I do not see any problems with this.

You have wrong Regular expressions.

Please be more respectful to another people. You've made a mistake, according to what I see in your initial post.

{name:[\x7F-\xFF]+} {name:[а-я]+/u} {name:[а-я]+#u} doesn't work... How I can use russian in route?

that why regular expressions you are defined not works.

#^/p/русский/мальчик/([а-я]+)$#u #^/p/русский/мальчик/([а-я]+/u)$#u

Do you see difference?