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?

1

2 Answers 2

3

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

Also check out:

Sign up to request clarification or add additional context in comments.

1 Comment

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!'; }
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.

2 Comments

I think you've misunderstood the question :) I'm not talking about plugins for a web application, but specifically for a framework.
thank you for pointing this out, understood. You wanted hooks. The links @Sarfraz are good enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.