简体   繁体   English

CodeIgniter-模块化?

[英]CodeIgniter - modular?

I'm building several sites that need similar "modules." 我正在建立几个需要类似“模块”的站点。 For example, the sites may have the exact same login system, forum, etc. 例如,这些站点可能具有完全相同的登录系统,论坛等。

Is there a way I could build these modules once and just "drop" them in these various sites? 有没有一种方法可以一次构建这些模块,然后将它们“拖放”到这些不同的站点中? Some of the challenges I see: 我看到的一些挑战:

  • Keeping the code consistent in the various sites. 在各个站点中使代码保持一致。 Any changes made to a module should propagate to all of the sites using that module. 对模块所做的任何更改都应传播到使用该模块的所有站点。 I guess I need a way to upgrade? 我想我需要升级的方法吗?
  • Database: these functionality need to work as part of a bigger application. 数据库:这些功能需要作为更大的应用程序的一部分来工作。 Maybe the module needs to define relationships with other tables in its respective site. 也许模块需要定义与其各自站点中其他表的关系。

I'm sure there are more problems. 我确定还有更多问题。 I think I should be looking at this: https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home , but I don't have any experience with it. 我想我应该看看这个: https : //bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home ,但是我对此没有任何经验。

So, I'm looking for solutions, suggestions, or more problems to this idea. 因此,我正在寻找有关此想法的解决方案,建议或更多问题。

I would write them as libraries and use Git submodules to manage each module . 我将它们编写为库,并使用Gi​​t子模块来管理每个模块 Phil Sturgeon actually just wrote a great post about doing this in CodeIgniter . 实际上,Phil Sturgeon 在CodeIgniter中撰写了一篇很棒的文章

If you're not using version control, I can't see an easy way to sync across all of your applications. 如果您没有使用版本控制,则看不到在所有应用程序之间进行同步的简便方法。 Yes, HMVC will let you break apart your application into actual modules, but it won't help in syncing those modules across your applications. 是的,HMVC可以让您将应用程序分解为实际的模块,但是在整个应用程序中同步这些模块无济于事。

You can create and use third party packages by adding them to the third party folder (which is new for CI 2). 您可以通过将第三方软件包添加到第三方文件夹(对于CI 2是新的)来创建和使用第三方软件包。 There is not much about it in the docs, but i found this. 在文档中没有太多关于它的内容,但是我发现了这一点。

http://codeigniter.com/user_guide/libraries/loader.html http://codeigniter.com/user_guide/libraries/loader.html

You can autoload the third party packages in the autoload file. 您可以在自动加载文件中自动加载第三方程序包。 Packages can have their own controllers, models, views etc. 包可以具有自己的控制器,模型,视图等。

Interestingly, Phil Sturgeon wrote a bit (http://philsturgeon.co.uk/blog/2010/04/codeigniter-packages-modules) about packages not being modules (in the strict sense of the term), but you could probably use third party packages for what you need. 有趣的是,Phil Sturgeon写了一些(http://philsturgeon.co.uk/blog/2010/04/codeigniter-packages-modules)关于包不是模块的信息(严格意义上来说),但是您可以使用您需要的第三方软件包。

Here is my question about ' Database communication in modular software ' 这是我关于“ 模块化软件中数据库通信 ”的问题

that you may find useful. 您可能会发现有用。

I'm little bit familiar with Drupal, and as a modular application, I think it can be taken as good example of how relationships between modules should be defined. 我对Drupal有点熟悉,并且作为模块化应用程序,我认为它可以作为如何定义模块之间关系的很好的例子。

Here is one good post about art-of-separation-of-concerns 这是关于关注点分离艺术的一篇好文章

I would like to hear if you have run into some concrete challenges, solutions and references concerning modular design in CI. 我想听听您是否遇到了有关CI中模块化设计的一些具体挑战,解决方案和参考。

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

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