简体   繁体   English

CodeIgniter HMVC:扩展库还是创建全局控制器?

[英]CodeIgniter HMVC: extend a library or create a global controller?

I've started using HMVC in Codeigniter with Modular Extension and i want to create a set of methods avalaible in the whole application. 我已经开始在带有Modular Extension的Codeigniter中使用HMVC,并且我想在整个应用程序中创建一组可用的方法。

For example i've this three methods: 例如,我有这三种方法:

  • a method to retrieve te app name 一种检索应用名称的方法
  • a method for getting the right view folder depending on the user agent 根据用户代理获取正确的视图文件夹的方法
  • a method to load assets 一种加载资产的方法

What's the best way to do this: 最好的方法是什么:

  1. I'm using a model inside a module which is then requested from all other modules 我在模块中使用模型,然后从所有其他模块中请求
  2. I may extend or create a library/helper 我可以扩展或创建一个库/帮手

now i'm using the first solution but I have come to doubt that it can slow down the application. 现在我正在使用第一个解决方案,但是我开始怀疑它会减慢应用程序的速度。

I would put this one in a base controller. 我会将其放在基本控制器中。 Like this one: https://github.com/jamierumbelow/codeigniter-base-controller 像这样的一个: https : //github.com/jamierumbelow/codeigniter-base-controller

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM