Unload dynamic class in PHP -
I have loaded the plugins in the following ways:
function process plugin ($ plgFile , $ Db) {require_once ($ plgFile); $ Plgin = new PlginImpl (); $ Plgin- & gt; SetDb ($ Database); $ Ret = $ plgin- & gt; process (); Return $ ret; } Each plugin defines a class named PlginImpl , which works fine. But it is possible to call more plug-in calls specified within the return value of process () .
Please note that each plugin is:
A class, that is:
class implements the PlginImpl plugin PluginInterface plugin defines PluginInterface while providing some useful functions i.e. process () .
I think the name of all the plugins is PlinyImpleplut, hence the cause of the problem, so my question is: One way to unload a class ( PlginImpl ) it is < After loading with code> need_once ? Or should I follow a completely different approach?
Edit I tried without following the following things:
- Unset
$ PlginAfterprocess () - calling
__ destruction ()- it does not work withinprocessPlugin ()Andprocessmethod
Many, many thanks!
Since you can not unload a category after loading it, only you have one The only option is to change the name of each plugin.
PluginX, PlugyY, etc. , But it will not make any difference because you can force them to use the plugin interface as you did.
To load a particular plugin, you can just give some suggestions like Solomongby, but rather than a file name, you name it a plugin. Something like this:
< Pre> function load plugin ($ pluginName) {require_once $ pluginName '.php'; $ Plugin = new $ pluginName; // $ plugin with whatever)
Comments
Post a Comment