Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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

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:


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:ьэё-асдявъ
        // Outputs: ьэё-асдявъ

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

        // URL:йцукенгшщзфывапролдячсмить
        // 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

  5. read doc
  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?