CodeIgniter Forums

Full Version: CICON2010 - Modular CI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4

El Forum

[eluser]WanWizard[/eluser]
First of all, cheers to Phil and Adam for organizing the first CI CON, in Bristol, UK, this weekend.

As with all 'first ones', things were a bit chaotic at times, but the presentations were good (great clip-art, Elliot! :lol: ), and speaking with your peers, and exchanging idea's, is always a good thing.

While discussing the new features of CI2, we realised that CI2 still doesn't have proper modules support, and that the new packages system doesn't really cut it. So, as today being designated as "CI Hack Day", I started to produce a library inspired by the new driver library, that add's module support to CI, so you can do this:
Code:
// you can also use autoload to load this library
// in that case, use the module config file to define the path
$this->load->library('module', array('path' => 'modules') );

// Make the "my_module" module available to us
$this->module->load('my_module');

// call a method in a library of our module
$this->my_module->library->testlib->func('varA', 'varB');

// call a method in a model of our module
$this->my_module->model->testmodel->func('var1', 'var2');

// call a method in a controller of our module
$this->my_module->controller->testcntrlr->func('varX', 'varY', 'varZ');

// load a view from our module
$this->my_module->view('test');

// load a helper from our module
$this->my_module->helper('test');

// and see if it works
testhelper();

Probably more features are needed, but hack day is comming to an end, and the pub awaits...

EDIT: Bummer, can't attach the zip file: Error Message: The file you are attempting to upload has invalid content for its MIME type.
???

EDIT: tried zipping on Linux and uploading with FF/Linux, used Winzip and IE & FF on Windows for upload. All the same error message. Upload is seriously broken!

El Forum

[eluser]gyo[/eluser]
This sounds great!
I can't wait to see the library... Wink

Please let us know, thanks!

El Forum

[eluser]danmontgomery[/eluser]
Very interesting... I have many questions, but I will wait until I see the code Wink

El Forum

[eluser]WanWizard[/eluser]
It's just a start, we didn't have that much time, and coding with a laptop on your lap isn't actually that handy... :lol:

I'm still baffled why I can't upload the zip. Tried everything, even uploading it as a tarball won't work. <grrr>

El Forum

[eluser]gyo[/eluser]
Did you try uploading it in the wiki?

El Forum

[eluser]WanWizard[/eluser]
The Wiki gives exactly the same error... >Sad

El Forum

[eluser]danmontgomery[/eluser]
Github/Bitbucket?

El Forum

[eluser]WanWizard[/eluser]
This will do: http://www.exitecms.org/files/ci_modules.zip.

Note that this uses a 'module' library at the moment. It would probably be cleaner to extend the loader library, so you can do $this->load->module(). I currently use the module library mainly because I need a way to configure the modules path. In case of a loader extension, that probably has to go in config/config.php, which makes it less clean.

El Forum

[eluser]gyo[/eluser]
Hi WanWizard,

I like this, simple and clever. And it perfectly fills the gap between 'modules'.

But, don't you think that 'modules' should also be reached via URI, like normal controllers?

Thanks for sharing!

El Forum

[eluser]WanWizard[/eluser]
You are thinking about modular separation, HMVC, the lot.

That was not the intention of this exercise.

The idea here was that you have a main CI app that does all the backend stuff, the theming and templating, but no business logic. I call it an application framework.
You then create independent modules (like little CI mini apps) containing the business logic. These are called from the main app (using some logic), and will produce a partial (element, widget, ...) that will be integrated in the output by the main app.

So instead of calling "controller/method" that has to generate an entire html page, the framework calls that method, and the result is a partial that the framework will integrate in a page using a template system. So instead of using the standard paradigm of CI to hardcode everything, and to have a one-to-one mapping between the URI and a controller, you create a much more dynamic application.

It is mainly useful for web applications, not for semi-static public websites. It allows a developer to focus on the business task at hand, without having to worry about all the housekeeping stuff that every application needs, and that you have to setup, build, and rework every time you have to develop an application. Which is what I'm trying to archieve with ExiteCMS (which is, contrary to the name, not a CMS, but has modules so you could turn it into one if you want).
Pages: 1 2 3 4