Reputation: 3861
OK. I am creating a completely AJAX and web2.0 Project Management System. Since every company is diffrent, I would like developers to be able to make plugins, like WP does.
My system is currently setup where I made a good API in PHP (incase I expand to iOS/Driod) and the site has AJAX calls to it to get the data it needs.
For instance a plugin that allows the page to track your time on each project.
MY QUESTION: How do I write a jQuery/LAMP site that allows plugins? I cant exactly wrap my head around how that would work. Of course all plugins would be submitted through me and only allow ones I have reviewed.
None the less, I am lost :/
THANKS FOR YOUR HELP IN ADVANCE!
Upvotes: 4
Views: 270
Reputation: 1451
Expose your API through interfaces for users to build their plugins around. If the plugins may also deliver content, you'll have to deal with where the content is stored, how it's retrieved, and theme-ing/skinning support.
You'll need to account for enabling/disabling the plugins, as well as some sort of life-cycle (albeit simple) architecture for a plugin designer to coordinate when/where the plugin is activated and used.
Upvotes: 1
Reputation: 20440
You could see how other systems do it, like Wordpress, Drupal or Symfony. I'd have a database table for plugins, and a 're-scan' function that goes through the relevant folder looking for changes (upgrades, deletions, additions).
You'll also need to add 'hooks' into your code so that, if a custom method exists, it is called as well as (or instead of) your default handler. This can get quite complicated, mind :)
Upvotes: 1
Reputation: 2275
I would have done it this way: each plug-in is a directory ("./Pluginname") which contains main file (./Pluginname/Pluginame.php). Pluginame.php contains a class named "Pluginame" whose instance will be created each time, if this plugin will be enabled in the admin panel. So, this class contains some functions that affect the future performance of the code. You script must scan the plug-in directory and show all available plugins in admin panel module.
Next, if I writes a plugin for your Project Management System, I can test it in my local copy and send first version of my plugin to you. If you accepted it, you put my plugin in catalog of plugins in your site, where any user can download it in his own plug-in directory automatically.
Upvotes: 1