Plugins (like Swift)

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Plugins (like Swift)

Post by onion2k »

I'm building an application that interacts with forum boards .. getting various bits of information like posts and users online. I'd like to be able to be able to add definitions for particular forums .. eg IPB, phpBB, custom boards. I've read the code and docs for Swift, and I really like the plugins idea. I'd rather like to implement a similar sort of thing .. but I'm not 100% on exactly how it works. What should I plan prior to attempting to write a plugin system?

Or.. is this a daft way of doing this?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Plugins (like Swift)

Post by Chris Corbyn »

onion2k wrote:I'm building an application that interacts with forum boards .. getting various bits of information like posts and users online. I'd like to be able to be able to add definitions for particular forums .. eg IPB, phpBB, custom boards. I've read the code and docs for Swift, and I really like the plugins idea. I'd rather like to implement a similar sort of thing .. but I'm not 100% on exactly how it works. What should I plan prior to attempting to write a plugin system?
If you're going with the way it's done in Swift you might want to have a read of a discussion here: http://www.sitepoint.com/forums/showthread.php?t=379440

For something like Swift's plugin system to work you really need to be willing to put key items into public properties so that they can be modified in the plugins. Another approach would be to have public accessors to grab these items but it doesn't really make a difference. I think it was arborint who said that perhaps passing items as parameters wuld be a good idea, but my only reservation was how do you know for sure that the plugin author wants access to that particular item even though that might seem like the obvious thing to do.

It's dead simple how it works.... all it's doing really is checking to see if a method exists in a loaded object and running it if it's there.

I've been looking at how other people are implementing plugins but they seem to presumtious about what the plugin should be doing so I haven't grown on some of the ideas. ~dreamscape on sitepoint's play on what I've done is pretty cool with a really amusing example too :P

Bare in mind that this plugin system was written with the focus being on allowing several plugins to be loaded at once and having plugins respond only when asked to (some systems constantly check if the plugin is doing anything, this *asks* the plugin to do something).

Or.. is this a daft way of doing this?
Possibly :lol: To be honest I just made it up as I went along... seems to be playing nicely with me so far though... also seems to have been well received by some people who's view I appreciate :)
Post Reply