Plugin systems
| From: | Marcus Bointon | Date: | Tue, 31 May 2005 12:53:03 +0000 |
| Subject: | Plugin systems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-216041@lists.php.net to get a copy of this message | ||
I'm looking to build a plugin system for my web application. I'm going to need to handle multiple types of plugin. I know that many of them exist already, but I'm wanting something that's very object-clean and PHP5-aware. I was thinking about using multiple interface implementations, so that I could have a plugin that provides a particular kind of database access, provides a user interface for admin purposes, and a simple display unit perhaps for connection status. In this case I'd define a class like:
class mynewplugin extends pluginbase implements database, admin, display {
//...
}
I would then be able to introspect (using class_implements etc) to find, for example, all plugins that implement database access. I could easily add more plugin types by adding more interface types. The overall benefit being that all kind of plugin are handled through a single mechanism.
Does this sound like a solid structure and mechanism?
Marcus
--
Marcus Bointon
Synchromedia Limited: Putting you in the picture
marcus@synchromedia.co.uk | http://www.synchromedia.co.uk