PHP插件系统:在我的应用程序中创建插件挂钩的位置?

问题描述:

I want to add a plugin system to my PHP application.

I'd like to create a hook system where my plugins register themselves to these hooks. So for so good. The problem is knowing from start what kind of hooks to create.

Are there any guidelines on how to do this? Should I have a hook for every point in the app where I might want to update data? Hooks for outputing data?

Would I need to have a hook for something like "before_script_ends", "before_avatar_output"?

我想在我的PHP应用程序中添加一个插件系统。 p>

I 我想创建一个钩子系统,我的插件将自己注册到这些钩子。 所以这么好。 问题是从一开始就知道要创建什么样的钩子。 p>

有没有关于如何做到这一点的指导方针? 我是否应该为应用程序中的每个点添加一个钩子,我可能想要更新数据? 用于输出数据的钩子? p>

我是否需要为“before_script_ends”,“before_avatar_output”之类的东西设置一个钩子? p> div>

This seems pretty opinion based...

I'd start with requirements of what your developers are asking for in this plugin system. Try just kicking it off thinking about minimum viable product. What things would be most beneficial. I'd vote with routing type features so probably create hooks for that. That may actually be all you need.

Also decide if a plugin system is what you want. You might prefer more separated apps. In which case a rest based/oauth like approach might be more appropriate.

It is hard to say with out some specific use case.