hadi
hadi

Reputation: 95

How to create thread in laravel 5.6?

In need run other function without stop.

How to use thread in laravel 5.6?

For example:

public function index()
{
     $id = "123456";
     $this->run_bot($id);

     return view("index");
}

Funtion run_bot it takes about 10 minutes !!!!

I need run run_bot in a thread.

How to craete thread in laravel 5.6?

Upvotes: 1

Views: 1947

Answers (2)

Florian Laforgue
Florian Laforgue

Reputation: 299

The solution you are looking for is how to run asynchronous jobs. This can be done with a queue service (like AWS SQS) and the Laravel queue worker.

It will allow you to send the job (really light work so it's really speed). And then, asynchronously, retrieve and execute the job.

Everything you will need to know is here :

https://laravel.com/docs/5.6/queues

Let me know if it helped you :)

Upvotes: 0

user320487
user320487

Reputation:

Look into Symfomy's Process Component.

As an example, you can start the process and then later wait for it to complete:

$process = new Process('ls -lsa');
$process->start();

// ... do other things

// this is optional, you don't need to wait if not necessary
$process->wait();

Upvotes: 2

Related Questions