Bind and get specific files from a Puli Repository with Puli Discovery

Code
<?php

use Puli\Repository\FilesystemRepository;
use 
Puli\Discovery\InMemoryDiscovery;
use 
Puli\Discovery\Api\Type\BindingType;
use 
Puli\Discovery\Binding\ResourceBinding;
use 
Puli\Discovery\Binding\Initializer\ResourceBindingInitializer;

$dir '/path/to/dir';

$repo = new FilesystemRepository($dir);
$bindingInit = new ResourceBindingInitializer($repo);

$discovery = new InMemoryDiscovery([$bindingInit]);
$discovery->addBindingType(new BindingType('text'));
$discovery->addBinding(new ResourceBinding('/*.txt''text'));

$bindings $discovery->findBindings('text');

foreach (
$bindings as $binding) {
    echo 
$binding->getType()->getName() . PHP_EOL;
    foreach (
$binding->getResources() as $resource) {
        echo 
'- ' $resource->getPath() . PHP_EOL;
    }
}
Result
text
- /de.txt
- /it.txt
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6