title: php - Autoloader implementation, preload all the classes
body: <p>I'm new to php and inherited a website project with hundreds of pages, all procedural (when I do a text search of the files, there isn't even a function definition anywhere). I'm coming from the c# and Java worlds. I'm looking for a way to incrementally add OOP. (They want me to update the front end and I am trying to convince them of fixing the backend at the same time and they don't want to use a framework (dammit)).</p>
  
  <p>While looking into autoloader...  Well, here's my understanding. It's a method of registering folders where classes are stored and when you instantiate a class, trait, etc. it searches the folder based on the class/filename/namespace and loads the appropriate definitions.</p>
  
  <p>I have a few questions:</p>
  
  <p>Does autoloader search the folder and load the appropriate definitions on every page lifecycle (or does it cache them)? </p>
  
  <p><strong>Pre-loading:</strong>
  Is there a way to use autoloader, or some alternative, to pre-load ALL class definitions into memory and make them available across all sessions? </p>
  
  <p>If so, when updating class files, how would I tell this mechanism to reload everything to memory when I make changes to class files?</p>
  
  <p>UPDATE TO QUESTIONS:</p>
  
  <p>Thank you both for your answers and it helps a little, but...  I do have a bad habit of posing the wrong question(s) on StackOverflow. </p>
  
  <p>The thing I want to avoid is slowing down pages by adding classes. So let's say I add a library and register the paths with autoloader. A page instanciates a class with multiple dependencies. Let's say that the dependency graph includes 15 files. For each request lifecycle, the server loads the page and 15 other files just on that one page. </p>
  
  <p>Since I am coming from compiled languages, I feel a little strange not loading these classes into memory. All the classes together should not be over say 5MB. </p>
  
  <p>(Or maybe I should just create a RAM Disk and copy all the files in there on boot and just have a symlink?)</p>