How To Capture Output From A Non-command Scheduled Task In Laravel?

- 1 answer

Given the following snippet:

    $schedule->call(function () {
        // echo "HELLO 123";   // nope
        // return "HELLO 123"; // also nope
        ->emailOutputTo('[email protected]');

The scheduled task is running, the emails are being generated, but with no content. I can capture output via the $schedule->exec and $schedule->command.

Ideal end state here is, run a few internal, non-command processes within the call method and output the results into a file/email.



I just googled the documentation of the class you are using with the words laravel scheduled output and the documentation (Just above the anchor in a red box) states:

Note: The emailOutputTo and sendOutputTo methods are exclusive to the 
command method and are not supported for call.

Hope that helps.