CodeIgniter - 模块化?
我正在构建几个需要类似“模块”的网站。例如,这些站点可能具有完全相同的登录系统、论坛等。
有没有一种方法可以让我构建这些模块一次,然后将它们“拖放到”这些不同的站点中?我看到的一些挑战:
- 保持不同站点中的代码一致。对模块所做的任何更改都应传播到使用该模块的所有站点。我想我需要一种升级方式?
- 数据库:这些功能需要作为更大应用程序的一部分来工作。也许该模块需要定义与其各自站点中其他表的关系。
我确信还有更多问题。我想我应该看看这个: https://bitbucket.org/ wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home,但我没有任何经验。
所以,我正在寻找这个想法的解决方案、建议或更多问题。
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.
So, I'm looking for solutions, suggestions, or more problems to this idea.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过将第三方包添加到第三方文件夹(这是 CI 2 的新功能)来创建和使用第三方包。文档中对此没有太多介绍,但我发现了这一点。
http://codeigniter.com/user_guide/libraries/loader.html
您可以自动加载自动加载文件中的第三方包。包可以有自己的控制器、模型、视图等。
有趣的是,Phil Sturgeon 写了一些关于包不是模块的文章(http://philsturgeon.co.uk/blog/2010/04/codeigniter-packages-modules)(在严格意义上的术语),但您可能可以使用第三方软件包来满足您的需要。
You can create and use third party packages by adding them to the third party folder (which is new for CI 2). There is not much about it in the docs, but i found this.
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.
我会将它们编写为库并使用 Git 子模块来管理每个模块。 Phil Sturgeon 实际上刚刚写了一篇很棒的 关于执行此操作的帖子在 CodeIgniter 中。
如果您不使用版本控制,我找不到在所有应用程序之间同步的简单方法。是的,HMVC 可以让您将应用程序分解为实际的模块,但它无助于在应用程序之间同步这些模块。
I would write them as libraries and use Git submodules to manage each module. Phil Sturgeon actually just wrote a great post about doing this in 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.
这是我关于“模块化软件中的数据库通信”的问题
,您可能会觉得有用。
我对 Drupal 有点熟悉,作为一个模块化应用程序,我认为它可以作为应该如何定义模块之间关系的一个很好的例子。
这是一篇关于 art-of-separation 的好文章-of-concerns
我想听听您是否遇到过一些有关 CI 模块化设计的具体挑战、解决方案和参考。
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.
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.