收集CakePHP 3外壳输出和错误

收集CakePHP 3外壳输出和错误,php,cakephp,Php,Cakephp,我发现了一篇文章,展示了如何将shell输出和错误重定向到cakephp2.x的文件,你知道如何使用cakephp3.x吗 下面是我为CakePHP 2.x找到的代码片段 public function __construct($stdout = null, $stderr = null, $stdin = null) { // This will cause all Shell outputs, eg. from $this->out(), to be written to

我发现了一篇文章,展示了如何将shell输出和错误重定向到cakephp2.x的文件,你知道如何使用cakephp3.x吗

下面是我为CakePHP 2.x找到的代码片段

public function __construct($stdout = null, $stderr = null, $stdin = null) {
    // This will cause all Shell outputs, eg. from $this->out(), to be written to
    // TMP.'shell.out'
    $stdout = new ConsoleOutput('file://'.TMP.'shell.out');

    // You can do the same for stderr too if you wish
    // $stderr = new ConsoleOutput('file://'.TMP.'shell.err');

    parent::__construct($stdout, $stderr, $stdin);
}
但是我得到了以下错误

PHP Fatal error:  Class 'App\Shell\ConsoleOutput' not found

ConsoleOutput是否在CakePHP 3.x中,如果是,名称空间是什么?

您需要使用下面的类,如:

use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOutput;

$output = new ConsoleOutput();
$io = new ConsoleIo($output);

但这似乎并没有将输出重定向到文件。。。知道为什么吗?是的,我试过了,它不起作用。。。我发布了一个新问题。。。