title: How do I reload a file in PHP?
body: <p>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?</p>
  
  <p>Here's some of my code:</p>
  
  <pre><code>$info = new \SplFileInfo("plugins/".$name."/".$main);
  include("plugins/".$name."/".$main);
  $class = new \ReflectionClass($name."\\".$info-&gt;getBasename(".php")); //Taking care of using the correct namespace
  $this-&gt;class = $class-&gt;newInstanceWithoutConstructor();
  </code></pre>
  
  <p>Running the exact same code twice results in the program crashing.</p>
  
  <p>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. </p>
  
  <p>Thanks for any help</p>