[This is a code coverage question, only that I hope to use it in production with the aim of pinpointing code that can be deleted.]
Is it possible to somehow record which files are part of an execution of PHP? That is, when a file is loaded as part of the execution of some entry point, is there a way to record this fact? I.e., when files are included, required or loaded as a part of classloading – in addition to the entry-point php file itself? (The classloading part is possibly the easiest, as you can handle the classloader yourself).
Background: I have a codebase with some legacy – and as a clean-up effort, it would be nice to delete the files which aren’t used anymore. This trick would give me a clue of which files are in use. Run this logging long enough, and you could simply delete all the untouched ones.
“Level 2”: Maybe files are included which actually aren’t used – i.e. some function library is included, but the execution never actually uses any functions there. How to track this? Is XDebug and other rather intrusive ways the only option?
If you are looking for files included :-
http://php.net/manual/en/function.get-included-files.php
To track list of the class loaded, Xdebug should be the best choice.
Or the APD : Advanced PHP debugger
Take a look on the
apd_callstack, you could find something surprise there.