Reputation: 2994
I found a post that shows how to redirect the shell output and errors to files for CakePHP 2.x, any idea on how I can do so with CakePHP 3.x?
Here is the code snippet I found for 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);
}
But I am getting the following error
PHP Fatal error: Class 'App\Shell\ConsoleOutput' not found
Is ConsoleOutput in CakePHP 3.x and if so, what is the namespace?
Upvotes: 1
Views: 393
Reputation: 4205
You need to use class below like:
use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOutput;
$output = new ConsoleOutput();
$io = new ConsoleIo($output);
Upvotes: 1