php - 如何增加 Laravel Controller 方法的执行时间?

标签 php laravel execution

我想将我的 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/

相关文章:

php - 响应在 PHP 命令行上运行的程序提出的问题

php - 让 PHP7 和 PHP 8 共存

php - 如何使用 PHP/MySQL 搜索其他变量的特定内容?

php - 想要在 URL 包含特定字符串时抛出 404 错误 - Wordpress

laravel - 如何在scss中获取环境变量

javascript - 在 Laravel 中使用 Pusher 监听消息

javascript - 停止所有 javascript 执行

sql - 识别何时在 SQL 查询或 PL/SQL 过程中执行函数

php - 将组数据填充到 Highcharts 上的特定系列

php - Laravel 重定向与注销不起作用