List directories with php and compare them

Sometimes it’s important to quickly highlight differences between two folders structure.

It could happen expecially when you are obliged to work on cheap environments, without console and you need to understand if there are differences among your local filesystem and the remote one.


$dir = __DIR__;
$scan_result = scandir( $dir );
foreach ( $scan_result as $key => $value ) {
  if (!in_array($value, array('.', '..'))) {
    if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
      print $value."<br/>";

You can copy the script in each directory and naming it scandir.php, than reach it by browser at the url http://path-to-your-base-folder/scandir.php.

In this way you have just executed the script, do it on each environment directory and occasionally compare them.

To compare there are Notepad++, git diff, WinMerge and plenty of open source tools.

Scandir is a php function, check it, I have wrote this code using an example I found there.