core
core copied to clipboard
Mapping paths should allow arbitrary files
Description
The mapping paths configuration currently only supports directories. This means that it must search all files within the directory for api resources. However, when tests are located next to code (as is done in other languages), this means that tests are also searched for resources. This slows down the container building as there are more files to be searched, as well as invalidates cache whenever a test changes.
It would be great to be able to specify the individual files to be checked instead of the directories that contain them.
Example
$paths = Finder::create()
->in(__DIR__ . '/../src')
->notName('/.*Test.php/')
->files();
$apiPlatform
->mapping()
->paths(array_map(fn ($path) => $path->getRealPath(), iterator_to_array($paths)));