Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

php - How to save/redirect output from Laravel Artisan command?

I'm using Artisan::call() in one of my routes and would like to save the command output to a variable.

Is there any way to capture the STDOUT and STDERR generated by the artisan command?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This is a way:

use SymfonyComponentConsoleOutputBufferedOutput;

Route::get('/test', function()
{
    $output = new BufferedOutput;

    Artisan::call('list', array(), $output);

    return $output->fetch();
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...