PHP program analysis

I offer a PHP program to work. However, this program has been handled by several different people for many years. Things have been removed and added over time. But most files are still there.

I was wondering if there is a tool there that can parse a PHP program. for example, submit it to index.php and this tool will check and see that the witches files are being called and used, so I can remove all the dead wood that is no longer in use.

I planned to write it myself, but someone else could do something similar.

Any suggestions are welcome, thanks! Mike

+5
source share
3 answers

, , , . - grep ( "grep grep", , ) "include" "require". , deceze ( , ), , , " ".

, , .

+3

, xdebug , , .

:)) , . , .

, , , , amazon.

+1

, , get_included_files(). , include.php, - auto_append_file. . , , , include.php, , .

<?php
function writeIncludes( array $includes ) {
  $filename = __DIR__ . '/included.php';

  $output = "<?php\nreturn ";
  if( file_exists( $filename ) ) {
    $files = include( $filename );
  }
  else {
    $files = array( );
  }

  $files = array_merge( $files, $includes );
  $output .= var_export( $files, true );

  file_put_contents( $filename, $output );
}

writeIncludes( get_included_files( ) );

Of course, this script is not useful for debugging other than your current setup, but it should be fast and fast enough. It may be ugly, but he will do his job.

+1
source

All Articles