Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用finder在日志目录中打开文件_Php_File_Symfony - Fatal编程技术网

Php 如何使用finder在日志目录中打开文件

Php 如何使用finder在日志目录中打开文件,php,file,symfony,Php,File,Symfony,我试图用Finder()在app/logs/myfile.log中打开一个日志文件,但我真的不知道该怎么做,原因不是很明确 我尝试在控制器中执行此操作: use Symfony\Component\Finder\Finder; class LogController extends Controller { public function indexLogListAction() { $finder = new Finder(); $test =

我试图用
Finder()
app/logs/myfile.log中打开一个日志文件,但我真的不知道该怎么做,原因不是很明确

我尝试在控制器中执行此操作:

use Symfony\Component\Finder\Finder;

class LogController extends Controller
{
    public function indexLogListAction()
    {
        $finder = new Finder();
        $test = $finder->files()->in('myfile.log');
        var_dump($test);exit;
    }
}
但它返回以下错误:

“myfile.log”目录不存在


我的控制器位于
src/acme/bundle/controller/mycontroller.php

中的方法
Finder
实例中设置目录,该目录将进行搜索

$finder = new Finder();
$finder
  ->in('path/to/log/directory') // Search in directory
  ->files() // Search only files
  ->name('myfile.log'); // File name pattern search

您需要指定路径。