开发者

Modular architecture in CodeIgniter

the idea

I'm playing with a concept of modular website builder - now mostly in theory, which would containt pages / collections based on modules (either preprogrammed or done specifically when needed).

Every module with come with it's ties to DB, views/templates and core data processing, I'm thinking about factory pattern:

basic module wrapper - having normalized names -> callDB, processData, returnToTemplate

each module then inherits this wrapper and just adds it's calls to DB, it's data processing and finally will return to data, then in application, I will just do something like:

$this->modules->each->callDB(); //obviously, pseudo-PHP

th开发者_高级运维e problem

What am I struggling with, however, is incorporating this whole idea into CodeIgniter's MVC approach and it's data structure, so it won't be/feel (i know, subjective) unnatural and/or meaningless.

Any ideas?

(under tree structre i - i know, that i can do whatever i like. However, I don't know if I like dir modules with subir for each module, or templates in application/templates and modules in application/modules - and those modules, it actually doesn't make sense to me, since my modules are somewhat different than CI modules... you know...)

edit1

So... is this so hardcore or so dumb that there are no answers??


What exactly are you trying to achieve? There is plenty of code out there to help you achieve modular architecture (HMVC) in your CodeIgniter application.

Modular Separation - wiredesignz

Matchbox - Zacharias Knudsen

Anything else you need to add in relating to wrapping the module is purely in the implementation. I'd look into using MY_Controller and possibly taking it a step further to implement multiple base classes, so your frontend controllers know to wrap the module with whatever data from the DB.


There is a HMVC extension to codeigniter, check http://codeigniter.com/wiki/Modular_Extensions_-_HMVC/

Also you cand separate concerns in a modular way, by overloading CI's loader class (and routing if needed) and storing your MVC files in subfolders of application/models, application/views and application/controllers

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜