1

The Finder Symfony component is powerful, but unfortunately, you cannot sort founded files by size.

See below. I think it could be helpful, for me at least.

BntMrx
  • 2,187
  • 3
  • 18
  • 29

1 Answers1

1
<?php

$finder = new Finder();
$finder->files()
    ->in(__DIR__)
    ->sort(function (\SplFileInfo $a, \SplFileInfo $b) {
        return filesize($a->getRealpath()) < filesize($b->getRealpath());
    });

foreach ($finder as $file) {
    echo filesize($file->getRealpath()) . PHP_EOL;
}

That's it!

BntMrx
  • 2,187
  • 3
  • 18
  • 29