Instead of using file paths, use Puli repository

Code
<?php

use Puli\Repository\FilesystemRepository;

$dir '/path/to/dir';

$repo = new FilesystemRepository($dir);

echo 
'<h3>File resource:</h3>';
$fileResource $repo->get('/foo.yml');
dump($fileResource->getBody());
dump($fileResource->hasChildren());

echo 
'<h3>Directory resource:</h3>';
$dirResource $repo->get('/Foo');
dump($dirResource->hasChildren());

echo 
'<h4>All files in directory:</h4>';
foreach (
$dirResource->listChildren() as $fileResource) {
    
dump($fileResource->getPath());
}

echo 
'<h4>One file in directory:</h4>';
dump($dirResource->getChild('Foo.php')->getPath());
Result

File resource:

"""
foo:\n
bar: value1\n
foo: value2
"""

false

Directory resource:

true

All files in directory:

"/Foo/Foo.php"

One file in directory:

"/Foo/Foo.php"
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6