【问题标题】:Symfony Finder - "The "1" directory does not existfSymfony Finder - ““1”目录不存在f
【发布时间】: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 有谁知道如何访问特定文件,而不仅仅是搜索文件夹?文档不是很清楚。

【问题讨论】:

    标签: php symfony finder


    【解决方案1】:

    $finder->in(...)返回$this

    所以替换

    $finder->files()->in($finder->in(__DIR__.'/../BusinessLogic'));

    通过

    $finder->files()->in(__DIR__.'/../BusinessLogic');

    【讨论】:

      猜你喜欢
      • 2019-09-25
      • 2015-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-19
      相关资源
      最近更新 更多