Yii- How to add urlManager rules to a module?

In the Yii structure, the main configuration file defines the components. one of which is urlManager:

'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'rules'=>array('/'=>'site/homepage', //... 

cool I like it working. Now I am creating a module and this module, I want to have some routing rules that are specific to the module. I want / myModule / moduleController / action /: id to point to an action and pass the identifier along with it. but I don’t want to touch files outside the module. I think you can do this in myModuleModule.php file.

I found the link http://www.yiiframework.com/forum/index.php/topic/25801-url-rules-in-module-definition/ about one way to do this, but it seems to be hacked and not perfect.

So my question is: what is the best way to add urlManger rules to a module?

+4
source share
1 answer

I think that this weak point in the management of Yii - Url from inside the module is not implemented (or designed) well. I have not read this whole stream , but it seems that this weak point has not escaped the attention of the Yii dev team and their thought / thought solution. AFAIK, meanwhile, with the same breath, when you load the module, you need to set the URL manager rules in the configuration file.

+2
source

Source: https://habr.com/ru/post/1403717/


All Articles