Re: Plugin systems

From: Date: Tue, 31 May 2005 14:21:17 +0000
Subject: Re: Plugin systems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-216047@lists.php.net to get a copy of this message
Marcus Bointon wrote:
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 { //... }
seems like alot of spreadout functionality to be putting it in a single class (maybe I'm not seeing your example in the proper light).
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?
it sounds like lots of work, with the possibility that it will become overengineered... which has the affect of: 1. making code slow (introspection and reflection are not the speediest parts of the engine!) 2. make seemingly simple things difficult because of all the hoops you have created for yourself. but then there is nothing to suggest that you can't make it work - the kind of thing you suggest doing is a good way of utilizing the advantages of the object model. I doubt it will be easy to write it well... but hey thats half the fun right?! :-) by all means hit the list with all your tricky little php5 problems, I for one will be on the look out for them :-) btw: you may want to ask yourself (in order to help define scope etc): 1. what is the objective you wish to accomplish with such a 'system'? 2. do you have a very strict definition of 'plugin'? (I have always found the word rather woolly/inexact) rgds, Jochem
Marcus


« previous php.general (#216047) next »