Best way to allow plugins for a PHP application

前端 未结 8 755
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-27 09:12

I am starting a new web application in PHP and this time around I want to create something that people can extend by using a plugin interface.

How does one go about

8条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 09:41

    I am surprised that most of the answers here seem to be geared about plugins that are local to the web application, ie, plugins that run on the local web server.

    What about if you wanted the plugins to run on a different - remote - server? The best way to do this would be to provide a form that allows you to define different URLs that would be called when particular events occur in your application.

    Different events would send different information based on the event that just occurred.

    This way, you would just perform a cURL call to the URL that has been provided to your application (eg over https) where remote servers can perform tasks based on information that has been sent by your application.

    This provides two benefits:

    1. You don't have to host any code on your local server (security)
    2. The code can be on remote servers (extensibility) in different languages other then PHP (portability)

提交回复
热议问题