Reputation: 4556
I have a controller, lets say 'Foo' controller with function 'index' that takes a long time to execute.
I have a another controller, 'Bar' controller in which i want to process / call the 'index' function in the 'Foo' controller asynchronously.
class BarController extends \BaseController {
public function index()
{
// call the Foo controller here
}
}
Is there a way to call the 'index' function in the 'Foo' controller asynchronously?
Upvotes: 3
Views: 12341
Reputation: 60048
This is exactly what Laravel Queues are for. Move your command into a library somewhere, and call a method to 'queue' the command. Then it will be executed while your original controller can return to the user.
Upvotes: 10