【发布时间】:2018-07-25 08:11:49
【问题描述】:
所以我有一个文件(只是一个基本的文本文件),我想读入我的Controller,这样我就可以在树枝页面上显示输出。
我的代码(在我的控制器中)如下:
use Symfony\Component\Finder\Finder;
...
$finder = new Finder();
$finder->files()->in($finder->in(__DIR__.'/../BusinessLogic'));
foreach ($finder as $file) {
$contents = $file->getContents();
}
//return etc
鉴于控制器在src/Controller 中并且我要访问的文件在src/BusinessLogic 中,这应该可以工作,但它会出现一个错误页面,上面写着the "1" directory does not exist (InvalidArgumentException)。据我所知,它应该是有效的。
PS 有谁知道如何访问特定文件,而不仅仅是搜索文件夹?文档不是很清楚。
【问题讨论】: