Hooks in applications
I am trying to implement hooks in my application so that I can implement a plugin style architecture.
Trouble is I am not sure how to do this. My basic understanding is that the process goes like this:
1) system has to load up all active plugins
2) upon every systematic event, I need to dynamically call plugins registered with that event and perform the function that is specified in the plugin.
My idea was to just use my configuration file and create an array that lists all active plugins and there associated events and use a function naming convention for every initialization function of the plugin.
This way all i need to do is loop through the array looking for the plugin name and event associated.
How does this approach sound to others? Has anyone got any other ideas. My application is quite small and I dont really need a database so storing any plugin settings there is not really appropriate.
Any help or advice appreciated.
benf posted this at 09:09 — 23rd April 2010.
They have: 426 posts
Joined: Feb 2005
actually I found a good example of hooks and plugins on phpclasses.org here: http://www.phpclasses.org/package/4497-PHP-Setup-and-call-application-pl...
This is something that could be elaborated on I think. Ok so it is a simple as I imagined.
Good Value Professional VPS Hosting
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.