Bilal Hussain
Bilal Hussain

Reputation: 149

How to increase laravel controller method execution time?

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

}

Upvotes: 6

Views: 9789

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163968

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;
}

Upvotes: 10

Related Questions