3

First off, this isn't really a programming question but more of a programming concept question. Basically, I've built a bespoke PHP framework to speed up deployment on my end and I want some kind of plugin system in place that will allow me to add specific features to the base of the framework (like the SQL class or maybe a Twitter package) that will allow me to throw them into a folder and not have to actually edit the base for every new project.

Any ideas of the best way of going about this?

andy
  • 2,369
  • 2
  • 31
  • 50
  • possible duplicate of [Best way to allow plugins for a PHP application](http://stackoverflow.com/questions/42/best-way-to-allow-plugins-for-a-php-application) – ircmaxell Jun 13 '12 at 13:55

2 Answers2

3

Here is a nicely written post by @ircmaxell on how to do that and what are the options:

Also check out:

Community
  • 1
  • 1
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
  • I've had a look into this and it seems to be going in the correct direction according to what I want but I'm a bit perplexed. Would I have to go through my code and add certain notifiers to events so a plugin could run a piece of code there? For instance: `//Original code function save() { $this->anObjectsGotToDoWhatAnObjectsGotToDo(); $this->plugins->notify(); } //Plugin function recieveNotification() { echo 'Model saved!'; }` – andy Jun 13 '12 at 13:10
0

what im doing in my cms:

  • for each plugin i make a folder latin-named of this plugin's name.
  • i create a /translations folder in there too. Check here.
  • have a single php file that has 2 basic functions, the plugin_install and plugin_uninstall (you know, things to happen on install/unistall like tables creation/drop)
  • create a special page of your system that reads these plugins, installed and not and give an on/off switch so users can install/unistall them.
  • load these single files mentioned above by a single call to include_once on top of your index page (or administration page) so to include whatever functionality they offer.
  • enabled plugins will be loaded (include_once) from your main page, and also their functionality, so each plugin can call each other's as well.
Community
  • 1
  • 1
  • I think you've misunderstood the question :) I'm not talking about plugins for a web application, but specifically for a framework. – andy Jun 13 '12 at 13:13
  • thank you for pointing this out, understood. You wanted hooks. The links @Sarfraz are good enough. –  Jun 13 '12 at 18:22