How to solve a timeout error in Laravel 5
The Maximum execution time of 30 seconds exceeded error is not related to Laravel but rather your PHP configuration.
Here is how you can fix it. The setting you will need to change is max_execution_time
.
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)
You can change the max_execution_time
to 300
seconds like max_execution_time = 300
You can find the path of your PHP configuration file in the output of the phpinfo
function in the Loaded Configuration File
section.
it's a pure PHP setting. The alternative is to increase the execution time limit only for specific php scripts, by inserting on top of that php file, the following:
ini_set('max_execution_time', 180); //3 minutes
In Laravel:
Add set_time_limit(0) line on top of query.
set_time_limit(0);
$users = App\User::all();
It helps you in different large queries but you should need to improve query optimise.