Welcome Guest, Not a member yet? Register   Sign In
hooks to extend your own application's core files
#1

[eluser]gerben[/eluser]
I saw that Codeigniter has built-in hooks that enable you to extend the core libraries, without having to hack into them. I'm looking for a way to do the same, but in this case, with my own controllers and views.

I use Modular Separation, which works great if you want to add whole new parts (pages) to your system, but it would be even better if one could automatically include parts of code in certain parts of the main application, once the module has been dropped into place. This is specifically handy if you develop open-source software (like in my case).

I don't know if that explanation is clear enough, so let me give an example:

Let's say I have an application with which users can create pages, and I've created a module that allows users to add a contact-form to every page. Of course I could then edit the code of my main-application so that it inserts the contact-form-module logic and views into every page. But it would be much easier for users (and coders) if these parts would be automatically added in the right places in the main app, through the use of hooks.

So here's my question:
What would be the best way to implement such a system of hooks? Any ideas or examples are very welcome!
#2

[eluser]Pygon[/eluser]
I'm of the opinion that it's a bad idea. I wouldn't want a module I just dropped in to decide that it's going to implement itself into my administrative panel or my functions that return AJAX responses.

I think leaving it up to the user to determine where your module should be implemented is best.
#3

[eluser]gerben[/eluser]
Well, deciding WHERE each part of the module will appear will just be a lot easier though the use of hooks. Because the user can decide which hooks to plug into.

I mean: it's much easier to adjust one config file with hooks, than having to change code all over your application, just to plug in the hook. That's the whole thought behind this idea.

I want to make my software easy to use and understand, also for people who aren't programmers. So they can just download a module, and plug it in.
#4

[eluser]jbowman[/eluser]
I know this is a kind of old thread, but was wondering if anyone had any luck with developing something like they they'd like to share? If not, I guess if I ever get past the documentation phase of my project, I may give it a go if CI is what I go with.

Basically I'm envisioning a system where I can build hooks into my applications, that later I can key off of to manage my application additions better. ie: event based programming.

For example...

I create a user auth system. I define in the method that creates the a user 2 events "pre_user_create" and "post_user_create". Then for the user delete method I set up "pre_user_delete" and "post_user_delete".

pre and post, just in case.

Then say later I build an image gallery for my users, and I want each user to have their own gallery. So, my gallery module would need to hook onto the post_user_create and create an empty gallery for the user, setting up DB and file structure. Then it would also need to listen post_user_delete to clear itself out.

I'm basically looking around for frameworks that might be my best fit while I work on documenting the features and design for my project.




Theme © iAndrew 2016 - Forum software by © MyBB