oop - How do I reload a file in PHP? -
i including file used plugin in php application later instantiate class in using reflectionclass. now, reload whole file on runtime, can update code while program running. there way this?
here's of code:
$info = new \splfileinfo("plugins/".$name."/".$main); include("plugins/".$name."/".$main); $class = new \reflectionclass($name."\\".$info->getbasename(".php")); //taking care of using correct namespace $this->class = $class->newinstancewithoutconstructor();
running exact same code twice results in program crashing.
edit: plugin architecture consists of pluginmanager supposed load , unload plugins. unloading works fine. there's eventmanager used plugins subscribe specific events program or other plugins can fire. after unloading plugin, object of plugin never used again anything.
thanks help
it seems not quite idea php application. i'm not sure, may here answer on question , here link on runkit doc (found there in comments)
Comments
Post a Comment