2017-08-10 2 views
0

シェル出力とエラーをCakePHP 2.xのファイルにリダイレクトする方法を示す記事が見つかりました。どのようにCakePHP 3.xを使用することができますか?ここで CakePHP 3シェルの出力とエラーを集める

は、私は、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); 
} 

見つかりコードスニペットですが、私は、CakePHP 3.xので

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

がConsoleOutputです、次のエラーを取得していますし、もしそうなら、何があります名前空間?

答えて

1

あなたのような下のクラスを使用する必要がありますdoesntの

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

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

はしかし、出力をファイルにリダイレクトしているように見える...任意のアイデアなぜですか? –

+0

リンク:https://stackoverflow.com/a/11606218/5737771 –

+0

ええと、私はそれを試みました、うまくいきませんでした...私は新しい質問を投稿しました... https://stackoverflow.com/questions/45620364/cakephp -3-redirect-console出力ファイル –

関連する問題