1 year ago

Run Artisan command

Posted 1 year ago by sghimire

I have been trying to write a large file and calling artisan command from controller, command runs but I am getting time out all the time. Is there anyway to run this artisan command in queue from api(browser) then send it to run in the background like in the terminal, please?


Artisan::queue('test:ExecuteFile', ['filter' => $request->all(),'--queue' => $fileName]);


 public function queue($command, array $parameters = [], $queue = 'default')
            'Illuminate\Foundation\Console\QueuedJob', [$command, $parameters], $queue

public function handle()
        //getting the filter 
        $filter = $this->argument('filter');

        //getting optional values
        $queueName = $this->option('queue');

    $this->pathToFiles = storage_path() . '/temp/';

    //open the file and add first column's names
        $fp = fopen($this->pathToFiles . $fileName, 'w');
        fputcsv($fp, $columns);

    foreach ($ent as $v) {
        fputcsv($fp, array($v->tax, $v->tap4, $v->grp5, $v->genus, $v->host, $v->country, v->date, $v->id, $v->reg_number));


Please sign in or create an account to participate in this conversation.