开发者

Logic behind plugin system?

开发者 https://www.devze.com 2022-12-29 11:10 出处:网络
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

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开发者_JAVA技巧 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消