如何在PHP中重新加载文件?

I am including a File which is used as a plugin in a PHP application to later instantiate the class in it using ReflectionClass. Now, I would like to reload the whole file on runtime, so I can update the code while my program is running. Is there any way I could do this?

Here's some of my code:

$info = new \SplFileInfo("plugins/".$name."/".$main);
include("plugins/".$name."/".$main);
$class = new \ReflectionClass($name."\\".$info->getBasename(".php")); //Taking care of using the correct namespace
$this->class = $class->newInstanceWithoutConstructor();

Running the exact same code twice results in the program crashing.

Edit: My plugin architecture consists of a PluginManager which is supposed to load and unload plugins. Unloading works fine. There's also a EventManager which is used by the plugins to subscribe to specific Events my Program or other Plugins can fire. After unloading a plugin, the object of the Plugin itself is never used again by anything.

Thanks for any help

It seems not quite good idea for PHP application. I'm not sure, but may be here is the answer on your question and here is the link on RunKit doc (found there in the comments)