Skip to content

Instantly share code, notes, and snippets.

@samjarrett
Last active December 26, 2015 17:59
Show Gist options
  • Save samjarrett/5a6fa5ce9674450d8fd4 to your computer and use it in GitHub Desktop.
Save samjarrett/5a6fa5ce9674450d8fd4 to your computer and use it in GitHub Desktop.
#melbsf2 Symfony Components: Using Finder component (see http://samjarrett.github.io/Symfony2-Components-Presentation/pres.html)
<?php
// building from the last example...
use Symfony\Component\Finder\Finder;
$finder = Finder::create()
->files()
->in(__DIR__ . DIRECTORY_SEPARATOR . 'Command')
->name('*Command.php');
foreach ($finder as $file) {
$className = __NAMESPACE__ . '\\Command\\'
. $file->getBasename('.php');
$application->add(new $className);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment