PHP - Make an application that allows plugins

OK I am creating completely AJAX and web2.0 project management system. Since each company is different from each other, I would like for developers to be able to create plugins like WP.

My system is currently set up when I created a good API in PHP (if I am expanding to iOS / Driod) and the site has calls to AJAX to get the data it needs.

For example, a plugin that allows a page to track your time in each project.

MY QUESTION: How to write a jQuery / LAMP site that allows plugins? I’m leaning over, exactly wrap my head with how it will work. Of course, all plugins will be transmitted through me, and I will only allow those that I have a review.

However, I am lost: /

THANKS FOR YOUR HELP IN EXTENSION!

+4
source share
3 answers

You could see how other systems like Wordpress, Drupal, or Symfony do it. I will have a database table for plugins and a β€œre-scan” function that goes through the corresponding folder that is looking for changes (updates, deletions, additions).

You also need to add hooks to your code so that if there is a native method, it will be called just like (or instead of) your default handler. It can get quite complicated, mind :)

+1
source

I would do it like this: each plugin is a directory ("./Pluginname") that contains the main file (./Pluginname/Pluginame.php). Pluginame.php contains a class called "Pluginame", an instance of which will be created each time this plugin is enabled in the admin panel. Thus, this class contains some functions that affect future code performance. You script should scan the plugin directory and show all available plugins in the admin panel module.

Then, if I write a plugin for your project management system, I can check it in my local copy and send you the first version of my plugin. If you accepted it, you will put my plugin in the plugin directory on your site, where any user can upload it to their own plugin directory automatically.

+1
source

Provide your API through user interfaces to create your plugins. If plugins can also deliver content, you have to deal with where the content is stored, how it is extracted, and supports the theme / skinning.

You will need to consider the ability to enable / disable plugins, as well as some lifecycle architecture (albeit simple) for the plugin designer to coordinate when / where the plugin is activated and used.

+1
source

Source: https://habr.com/ru/post/1380921/


All Articles