{name:[\x7F-\xFF]+} {name:[а-я]+/u} {name:[а-я]+#u} doesn't work... How I can use russian in route?
|
Feb '16 |
6 |
803 |
0 |
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
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.
Tested this scenario and it works:
// Route
$router->add('/{slug}', 'Test::view')->setName('page');
// Controller
class TestController extends BaseController
{
public function viewAction()
{
die($this->dispatcher->getParam('slug'));
// 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 :)
need filter in route, before call controller.
What version for Phalcon do you use?
I have Phalcon 2.1.x and everything works fine.
<?php
use Phalcon\Mvc\Router\Annotations as Router;
$router = new Router(false);
$router->addModuleResource('frontend', 'Evc\Frontend\Controllers\Russian', '/p/русский');
$router->removeExtraSlashes(true);
return $router;
<?php
namespace Evc\Frontend\Controllers;
/**
* @RoutePrefix("/p/русский")
*/
class RussianController extends ControllerBase
{
/**
* @Get("/мальчик/{name:[а-я]+}")
*/
public function russianAction($name)
{
var_dump($name);
die();
}
}
var_dump($this->request);
protected '_matchedRoute' =>
object(Phalcon\Mvc\Router\Route)[50]
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?