How can I fix, or troubleshoot, Fatal Error Class not found with XHProf Module I'm seeing the following error when I enable xhprof in Drupal 8 either via Drush or via Composer. 


  Class 'Drupal\xhprof\RequestMatcher\XHProfRequestMatcher' not found in /var/www/mysite/docroot/core/lib/Drupal/Component/DependencyInjection/Container.php on line 272


I had xhprof working for a day or so, and randomly started seeing this issue. This feels very much like a Symfony/Composer autoloader issue to me, but I'm struggling with a technique or strategy for fixing or troubleshooting this. 

The Call Stack feels pretty useless in this context. 



I'm looking for any fix to this issue specifically, but I'm also looking for some technique or strategy for troubleshooting the missing class fatal error. The missing class error seems to keep cropping up for me with Drupal 8. I've tried to trace through the object hierarchy via xdebug, but Drupal 8 and Symfony, have a very abstracted object hierarchy. This makes it nearly impossible to be able to logically backtrack from where the error is thrown. 

Why is the class not found, even though the class is definitely here: docroot/modules/contrib/xhprof/src/RequestMatcher/XHProfRequestMatcher.php?

Update:

After trying everything I could think of, I decided to just try and rebuild my VM with: 

vagrant reload --provision 

Sure enough, the fatal error went away. Is there some cache somewhere that drush or Drupal Console wouldn't have access to? Maybe it has something to do with the RAM or OPCACHE as @cilefen mentioned?

Note that I do not have memcache or redis running on this VM. Per a conversation on the Drupal-VM issue queue I may have been able to solve the problem by restarting PHP or just doing a reload without having to do a --provision.
The backtrace what you see could be improved by adding the following settings in your xdebug.ini file:

; Data
xdebug.default_enable = 1           ; bool: The stacktraces will be shown by default on an error event.
xdebug.collect_vars = 1             ; bool: Gather information about which variables are used in a certain scope.
xdebug.show_local_vars=1            ; int: Generate stack dumps in error situations.
xdebug.collect_assignments=1        ; bool: Controls whether Xdebug should add variable assignments to function traces.
xdebug.collect_params=4             ; int1-4: Collect the parameters passed to functions when a function call is recorded.
xdebug.collect_return=1             ; bool: Write the return value of function calls to the trace files.
xdebug.var_display_max_children=256 ; int: Amount of array children and object's properties are shown.
xdebug.var_display_max_data=1024    ; int: Max string length that is shown when variables are displayed.
xdebug.var_display_max_depth=5      ; int: How many nested levels of array/object elements are displayed.
xdebug.show_mem_delta=0             ; int: Show the difference in memory usage between function calls.
xdebug.show_exception_trace=0       ; bool: Show a stack trace whenever an exception is raised.
xdebug.max_nesting_level=200        ; int: Controls the protection mechanism for infinite recursion protection.


This will give you more meaningful data.

Basically you're missing a class, so you should try to clear you caches and rebuild your registry. Also restart memcached/redis if it's in use.