2017-08-10 4 views
0

を提出する私は、CakePHP 3のファイルにCakePHPの3リダイレクトConsoleOutputは

をシェルからのコンソール出力をリダイレクトしようとしている私は、CakePHP 2のためのいくつかのスニペットを発見した、しかし、彼らが作業していないようです...ここで

は、私がこれまでに...

public $rootLogsDirectory = ROOT . DS . 'tmp' . DS . 'logs'; 
public $outputName; 

public function __construct($stdout = null, $stderr = null, $stdin = null) { 

    if(!is_dir($this->rootLogsDirectory)) { 

     mkdir($this->rootLogsDirectory); 
    } 

    $this->outputName = tempnam($this->rootLogsDirectory, 'cronjobs'); 

    $stdout = new ConsoleOutput('file://' . $this->outputName . '.out'); 
    $stderr = new ConsoleOutput('file://' . $this->outputName . '.err'); 

    $ioNew = new ConsoleIo($stdout, $stderr); 

    $ioNew->out('test'); 

    parent::__construct($ioNew); 
} 

しかし、$this->out('hello world')がファイルに書き込まれていないしているコードは、私が間違っているuse文を持っていた...

答えて

0

あり、私は

use Cake\Console\ConsoleOutput; 

use Cake\TestSuite\Stub\ConsoleOutput; 

からそれを変更しました