I have module structure in my Yii 2.0 application, so I need to call things like
"module/controller/action"
But 90% of modules and controllers have the same names, for example it looks like
"news/news/index"
"support/support/index",
"profile/profile/update"
It looks not good, I'd like to see just "profile/update"... Then I create the following rule in UrlManager:
"<controller:\w+>/<action:\w+>" => "<controller>/<controller>/<action>"
This gets me the error: "preg_match(): Compilation failed: two named subpatterns have the same name at offset 35"
How to solve this problem instead of creating different rules for each module, I don't want my config file has several rules for tens modules.
I found better solution. PCRE supports modifier "?J" that allows duplicate names for subpatterns. All we need is to add this modifier to our pattern that Yii will use for parsing url. Unfortunately we have to add it manually, in yii/web/UrlRule change line:
$this->_routeRule = '#^' . strtr($this->route, $tr2) . '$#u';
to:
$this->_routeRule = '#^(?J)' . strtr($this->route, $tr2) . '$#u';