How to solve a timeout error in Laravel 5

后端 未结 13 2072
说谎
说谎 2020-11-30 08:43

I have the following set up:

In routes I have:

Route::get(\'articles\', \'ArticlesController@index\');

The index method in the controller is simply:<

相关标签:
13条回答
  • 2020-11-30 08:59

    I had a similar problem just now. However, this had nothing to do with modifying the php.ini file. It was from a for loop. If you are having nested for loops, make sure you are using the iterator properly. In my case, I was iterating the outer iterator from my inner iterator.

    0 讨论(0)
  • 2020-11-30 09:04

    Sometimes you just need to optimize your code or query, Setting more max_execution_time is not a solution.

    It is not suggested to take more than 30 for loading a webpage if a task takes more time need to be a queue.

    0 讨论(0)
  • 2020-11-30 09:05

    Execution is not related to laravel go to the php.ini file In php.ini file set max_execution_time=360 (time may be variable depends on need) if you want to increase execution of a specific page then write ini_set('max_execution_time',360) at top of page

    otherwise in htaccess php_value max_execution_time 360

    0 讨论(0)
  • 2020-11-30 09:09

    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.

    0 讨论(0)
  • 2020-11-30 09:11

    If using PHP7, I would suggest you changing the default value in the public/.htaccess

    <IfModule php7_module>
       ...
       php_value max_execution_time 300
       ...
    </IfModule>
    
    0 讨论(0)
  • 2020-11-30 09:13

    You need to just press CTRL + F5. It will work after that.

    0 讨论(0)
提交回复
热议问题