I want to increase execution time of my controller method to 5 minutes . I searched but many times I found just one working idea that is increase the execution time in php.ini file but I do not want this I want to increase the execution time in laravel controller for one method only. Can any one tell me how I do that??? I tried many code one example is given below
public function postGetEvents1(){
set_time_limit(600);
//other code
}
Increase the execution time at php. ini level, max_execution_time=300. Use PHP at runtime to increase it, ini_set('max_execution_time', 300); //300 seconds = 5 minutes.
max_execution_time int. This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30 . When running PHP from the command line the default setting is 0 .
This should work for you, if you want to set higher execution time limit for just one method:
public function postGetEvents1(){
// Get default limit
$normalTimeLimit = ini_get('max_execution_time');
// Set new limit
ini_set('max_execution_time', 600);
//other code
// Restore default limit
ini_set('max_execution_time', $normalTimeLimit);
return;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With