我找到了一篇文章,展示了如何将shell输出和错误重定向到CakePHP 2.x的文件中,对如何使用CakePHP 3.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 foundConsoleOutput在CakePHP 3.x中吗?如果是,名称空间是什么?
发布于 2017-08-10 17:28:10
您需要使用下面这样的类:
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOutput;
$output = new ConsoleOutput();
$io = new ConsoleIo($output);https://stackoverflow.com/questions/45619973
复制相似问题