如何保存/重定向Laravel 5 Artisan命令的输出? [英] How to save/redirect output from Laravel 5 Artisan command?
本文介绍了如何保存/重定向Laravel 5 Artisan命令的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了此处描述的方法但这不适用于我的Laravel 5安装.
I have tried the method described here but this doesn't work on my Laravel 5 installation.
use Symfony\Component\Console\Output\BufferedOutput;
Route::get('/test', function()
{
$output = new BufferedOutput;
Artisan::call('testCommand', array(), $output);
return $output->fetch();
});
我的命令;
public function fire()
{
$this->info('No output visible');
}
任何建议我可能做错了什么?还是在Laravel 5中发生了变化?
Any suggestions what I might do wrong? Or is it something that has changed in Laravel 5?
推荐答案
我设法使用Artisan::output()
使其工作,该返回了最新命令的输出.
I managed to get this to work using Artisan::output()
, which returns the output of the latest command.
Route::get('/test', function()
{
Artisan::call('testCommand', array());
return Artisan::output();
});
应该为你做.
这篇关于如何保存/重定向Laravel 5 Artisan命令的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文