I have a command named MyCommand, and I am calling it from a job named MyJob. I cannot see the command outputs when it's called from job. But if I run the command directly from command line, command output is seen.
MyCommand.php code:
namespace App\Console\Commands;
use Illuminate\Console\Command;
class MyCommand extends Command
{
protected $signature = 'mycommand:doit';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$this->info('Process started');
//Some process is done here
$this->info('Process completed');
}
}
MyJob.php code:
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Artisan;
class MyJob implements ShouldQueue
{
public function __construct()
{
}
public function handle()
{
Artisan::call('mycommand:doit');
}
}