我想将我的 Controller 方法的执行时间增加到 5 分钟。我搜索但很多次我发现只有一个可行的想法是增加 php.ini 文件中的执行时间但我不想要这个我只想增加 laravel Controller 中一种方法的执行时间。任何人都可以告诉我我该怎么做吗??? 我尝试了很多代码,下面给出了一个示例
public function postGetEvents1(){
set_time_limit(600);
//other code
最佳答案
如果您只想为一种方法设置更高的执行时间限制,这应该适合您:
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;
}
关于php - 如何增加 Laravel Controller 方法的执行时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37509479/