CodeIgniter Forums
Suggestions for making "Addons" for a CI app? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Suggestions for making "Addons" for a CI app? (/thread-33319.html)



Suggestions for making "Addons" for a CI app? - El Forum - 08-22-2010

[eluser]bobbytb[/eluser]
Hello,

How would one make their CI app extensible via addons or modules?

I have a basic web-app that and would like to be able to "extend" the application's features via addons/modules that I can create in the future. My app is a basic reporting app, and in my case these addons would mainly consist of new reports that may be designed in the future.

Im borrowing the idea of addons/modules from CMSes such as joomla/wordpress/drupal etc.

Ideally, I would like the end user would be able to install these addons/modules using their browser (as opposed to ftping the files across).
The newly installed addons would then be integrated into their existing system.

I am sure this should somehow be possible with CI and I know its not trivial, but at this stage I dont even know where/how to start.

Any pointers to concepts or suggestions would be helpful and are welcome!


Suggestions for making "Addons" for a CI app? - El Forum - 08-22-2010

[eluser]pickupman[/eluser]
You could take a look at [url="http://bitbucket.org/philsturgeon/codeigniter-modular-separation/overview"]Modular Separation[/url]. You will also find info in the CI wiki. This allows you to put a set of controllers/models/views into subfolders.

As with addons for wordpress, the web gui just downloads the zips and then extracts the files into /wp-plugins. You could code the similar behavior where a user could upload a zip folder, and the contents are unzipped.

Give a look at [url="http://pyrocms.com/"]PyroCMS[/url]. It's built on CI and has these types of features.


Suggestions for making "Addons" for a CI app? - El Forum - 08-22-2010

[eluser]bobbytb[/eluser]
Hi Pickupman,

Thanks for taking time out and responding!

WOW! PyroCMS is amazing! Ive just installed it locally and its really awesome - with a lot of attention to detail and just the right level of functionality. I'm truly impressed!

Modular separation looks like it should do the trick for me! I will start playing around with Modular Separation MY_Loader/My_Router and see if I can migrate my existing app into more a modular one. That should also organize a bit of the code too.

PS. Looked at the links in your sig. Carabiner & Base Controllers also look pretty useful.

Thanks for the helpful reply Smile


Suggestions for making "Addons" for a CI app? - El Forum - 08-22-2010

[eluser]pickupman[/eluser]
Glad you found them useful. I found myself always using these great contributions to the CI community.


Suggestions for making "Addons" for a CI app? - El Forum - 08-22-2010

[eluser]CI_avatar[/eluser]
bob, we really appreciate your suggestion, but CI offers you more than that. Add-ons in CMS are fix little programs and ready to use for your CMS. But here in CI, addons can be compared as CI Libraries. You have to use it (a little writing of codes) to make things work.


Suggestions for making "Addons" for a CI app? - El Forum - 08-22-2010

[eluser]CI_avatar[/eluser]
bob, we really appreciate your suggestion, but CI offers you more than that. Add-ons in CMS are fix little programs and ready to use for your CMS. But here in CI, addons can be compared as CI Libraries. You have to use it (a little writing of codes) to make things work.


Suggestions for making "Addons" for a CI app? - El Forum - 08-23-2010

[eluser]bobbytb[/eluser]
[quote author="CI_avatar" date="1282549579"]bob, we really appreciate your suggestion, but .....[/quote]
I wasn't really making a suggestion, but looking for people to suggest on how to implement addons for my own app Smile

I am definitely looking at using modular separation to try and achieve this. Really should have done this a while back!


Suggestions for making "Addons" for a CI app? - El Forum - 08-23-2010

[eluser]CI_avatar[/eluser]
You can develop an installation controller first as part of your existing system. what it does is to unzip then copy the the controller,model,views from the module to the their respective directories.

sample module.zip (contains controller/controller.php, module/module1.php, module/module2.php, views/header.php, views/body.php, views/footer.php)

copy the content in view folder to the system view folder
copy the content in module folder to the system module folder
copy the content in module controller to the system controller folder

now you can use your module. but its just like copy and paste of folder, the problem is how to use the newly added module directly? I guess you need a table of your added modules and a controller the will handle the modules.


Suggestions for making "Addons" for a CI app? - El Forum - 08-23-2010

[eluser]WanWizard[/eluser]
Have a look at my alternative for Modular Separation: http://ellislab.com/forums/viewthread/164350/.

A lot less intrusive, supports both routing to module controllers (the modular separation way, but using simple route definitions) and calling module controllers from other controllers.
Supports all CI file types (controllers, libraries, models and views) in a module by using
Code:
// initialize our module
$this->load->module('modulename');

// call a module controller method
$this->modulename->controller->method();



Suggestions for making "Addons" for a CI app? - El Forum - 08-25-2010

[eluser]bobbytb[/eluser]
Thanks for the replies!

@CI-avatar, I think you're right. Upon installation, the module would write its properties/parameters into a modules table in the db. Then a controller can manage all installed modules, check versions etc.

@wanwizard, thanks for your suggestion. I'll give it a go too!