私は単純に「hello world」を CakePHP シェルからファイルに書き込もうとしていますが、最終的には製品モデルを使用して sitemap.xml ファイルを書き込もうとしています。私はこれを見つけました:私が始めた質問...
しかし、私は ConsoleOutput が Cake 1.3.6 (私が使用している) でサポートされていないか、それを保持するクラスを含める必要があると考えています。
ターミナルからファイルを実行しようとしたときに発生するエラー: PHP Fatal error: Class 'ConsoleOutput' not found in /public/vendors/shells/sitemap.php on line 7
これが私のコードです:
class SitemapShell extends Shell {
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);
}
public function main() {
// The following output will not be printed on your console
// but be written to TMP.'shell.out'
$this->out('Hello world');
}
}