so I have a file (just a basic text file) that I want to read in to my Controller
so I can display the output on a twig page.
My code (in my controller) is as follows:
use Symfony\Component\Finder\Finder;
...
$finder = new Finder();
$finder->files()->in($finder->in(__DIR__.'/../BusinessLogic'));
foreach ($finder as $file) {
$contents = $file->getContents();
}
//return etc
given that the controller is in src/Controller
and the file I want to access is in src/BusinessLogic
this should work, but it comes up with an error page saying the "1" directory does not exist
(InvalidArgumentException). As far as I can see it should be valid.
PS does anyone know how to access a specific file, rather than just searching a folder? docs weren't very clear.
$finder->in(...)
return $this
.
So replace
$finder->files()->in($finder->in(__DIR__.'/../BusinessLogic'));
by
$finder->files()->in(__DIR__.'/../BusinessLogic');