Vaidikalaya

Increase Maximum Execution Time In Laravel


When you run the large script in Laravel then it stops your script and shows an error that the maximum time is exceeded. So, In this tutorial, I will give you the solution that how to solve It.

There are many solutions to solve this error. But I will give you the best solution.


Solution 1: Set max_execution_time in the controller

Go to the controller in which this error is occurring and set the max_execution_time to 0:

set_time_limit(0);
namespace App\Http\Controllers;
use Illuminate\Http\Request;

class TestController extends Controller
{
    public function index(){
        set_time_limit(0);
       
        sleep(90);

        return "Hello Vaidikalaya";
    }
}

Solution 2: Using vendor directory

If you want to set the time limit globally then you need to set the time limit to 0 in the InteractsWithFlashData.php file which exists in the vendor directory.

Path of InteractsWithFlashData file:

Go to your Laravel application's - vendor/laravel/framework/src/ Illuminatehttp/Concerns/ InteractsWithFlashData.php

And add the set_time_limit(0);

set_time_limit(0);

Screenshots.