I am thinking about writing a content management system which allows user to use plugins written by other developers. It would allow me to easily update system functionality simply through creating and releasing plugins, as well as giving the user some power when it comes to using this system. However, I am faced with a problem... Which would be the best way to implement this design idea? I believe there is one way which I think could work but I need further insight upon this conjecture.

How about starting with a class, PluginManager, which would be responsible upon creation to scan a directory for plugins. These plugins would have to follow a distinct naming pattern to allow the manager to access the main class of the plugin. Suppose we have a directory, ../plugins/, which contains the plugins used by the system. Each of these plugins would need to be named after their primary class. For instance, SamplePlugin.php would contain a class SamplePlugin which the system would instantiate and utilize. The PluginManager would find this file, include it, and verify that it is a proper plugin.

Another important aspect of the plugin is that it must implement a protocol, or interface, that the system understands and takes advantage of to provide the link between system and plugin. I'm not sure how much power a plugin could be given or how much access to the system it could be granted but I am sure after some tests and examples I could figure out a way. There are a lot of holes in this design, but it's a place to start. I would like to be able to write plugins such as an XML-RPC interface, etc. Movable Type includes a plugin system which is used with HTML templates and output. I would also like to include this functionality. It's a rather complicated mess, come to think of it, but once I begin working on it or I get even clearer ideas from others will it begin to make sense.

Regards,
Eric Czarny

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to