Re: How to implement a plugin system?
| From: | Matt Zandstra | Date: | Mon, 06 Aug 2007 20:45:28 +0000 |
| Subject: | Re: How to implement a plugin system? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260249@lists.php.net to get a copy of this message | ||
You might want to take a look at stickleback:
http://sourceforge.net/projects/stickleback
Documentation is very thin on the ground right now, but there's a presentation here:
http://www.appulsus.com/resources/stickpres200706/img0.html
mz
On Mon, 6 Aug 2007, Hamza Saglam wrote:
Hello Boro, Thanks for your response. However I am looking for something a bit more comprehensive :) I could do it as you suggested if I had only a few plugins. As I am going to add loads of plugins over the time, rather than adding all the plugins one by one, could something like a 'loader' class be implemented? What I mean by that is, it will take the requested plugin names (with their own parameters necessary) and load/initialise them. In semi-psuedo-code, it would be something like: foreach plugin suplied as the argument include the plugin initialise it end Perhaps I should change the question to: "Do you think something like this would be efficient and useable? If not what sort of pattern would you follow?" Warm regards, Hamza. "Borokov Smith" <borokov@gmail.com> wrote in message news:46B77B4B.9020600@gmail.com...-- getInstance() http://www.getinstance.comHey Hamza, require_once($chosenPlugin . '.class.php'); $obj = new $chosenPlugin(); return $obj; And you can start from there. hth, boro Hamza Saglam schreef:-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpHello all, I am working on a project which needs to have some sort of plugins architecture and I am kinda stuck. Basically I want to give a list of items to the user, and according to his/her selection, I want to load relevant functionality into my application. I was thinking of having an abstract plugin class, and have the plugins implement that but then how would I actually load the plugins? Say for instance I want to load plugins X,Y,Z (and lets say i implemented them as [X|Y|Z].class.php) , should I just 'include' (or require) them? Or should I initialize all possible plugins and just pick the ones user has chosen (which sounds a bit pointless as it would load unnecessary stuff)? How would you go about doing something like this? Thanks.