How can I get the first file with symfony / finder ?
I tried to do like this:
<?php // ... $finder = new Finder(); $finder ->files() ->in($this->getKernel()->getRootDir().'/../web/uploads/') ->name($filename); if (!$finder->count()) { throw new NotFoundHttpException('Image not found'); } dump( $finder->count(), $finder->getIterator()->current(), $finder->getIterator()->valid() );
and I get this result:
1 null false
source share