My question is: How can I use laravel service containers to do heavy tasks. Actually I would like to use service containers to increase the performance.
Suppose we have the below class:
class HeavyTask
{
public function doHeavyTasks(){
}
}
and we define a service container for this class:
$this->app->singleton('HeavyTask' , function($app){
return new HeavyTask();
});
Suppose the class HeavyTask
is going to call too many api requests.
I will be thankful if you give me an example how can I call these requests api with a better performance. If we would like to define a scheduled task How can we do this?
$schedule->call(function(){
// do scheduled task
})->daily();
and I'll be thankful if you say what is the difference between the scenario we haven't used service container and the scenario we will use service container?(the difference between these two states performance)