Identifying what’s crap in your BLOATED PHP site and what’s not

  1. Register a shutdown function ref: http://php.net/manual/en/function.register-shutdown-function.php
  2. Call “get_included_files”
    ref: http://php.net/manual/en/function.get-included-files.php
  3. Save the returned file list to a log somewhere on your server.

This shouldn’t affect the response times – but be warned, it WILL generate higher disk I/O (which might in turn bottleneck at peak usage times).

Don’t let the size of the log file go up too much. Ensure crons/schedulers or any background processes use this shutdown function.

 

<?php
function shutdown()
{
 $xyzzy="";
 $included_files = get_included_files();
 foreach ($included_files as $filename) {
 $xyzzy .= "$filename\n";
 }
 file_put_contents($_SERVER['DOCUMENT_ROOT']."/shutdownlogger/incfiles.txt", $xyzzy, FILE_APPEND );
}

register_shutdown_function('shutdown');
?>