magento二次开发 - 访问模块中的controller

magento与别的框架的不同之处之一:路由规则通过xml文件进行配置
参考:《深入理解magento 第二章》

controller文件

之前我们新建了如下的模块,


magento二次开发 - 访问模块中的controller_第1张图片

完善一下HelloWorldController

如何访问controllers下的HelloWorldController.php呢?

修改模块配置文件的路由规则

编辑app\etc\config.xml



    
        
            0.0.1
        
    

    
        
            
                standard
                
                    Tencent_App
                    app
                 
            
        
    



同样,清除magento的缓存使得配置文件生效之后,我们在浏览器上请求
locahost/magento/app/helloWorld/say
那么就会访问到HelloWorldController下的sayAction
而请求

localost/magento/app/helloWorld

localhost/magento/app/helloWorld/index
就会访问到HelloWorldController下的indexAction

注:本地域名需要根据本地电脑的配置进行替换

你可能感兴趣的:(magento二次开发 - 访问模块中的controller)