I have an application in PHP (private CMS) that I would like to rewrite and add some new things – I would like to be able to extend my app in an easier way – through plugins
But the problem is – I don’t know how to achieve “pluggability”, how to make system that recognizes plugins and injects them into the app?
So, what’s the logic of a simple plugin system?
Normally plugins will all implement a common interface. The application using these plugins will load each plugin from a repository (e.g. libraries in a directory) and use the common interface to talk to them. You can extend this such that plugins implement one or more from a set of common interfaces.
Difficulties include determining what interface to define to be useful not just now, but for future plugins. You also need to worry about badly-written plugins. What happens if the plugin throws an exception ? Or perhaps if it ceases responding. Should you allow badly-performing plugins to bring down your system, or should you be isolated from this.