0

I have a problem with my code where I have to export CSV which has more than 100,000 data. But I am getting error like "Maximum execution time of 60 seconds exceeded".

I can not access to php.ini. Is it possible to to solve the issue without changing max_execute_time on php.ini ?

Yes, I can optimize code but I need to know, Is there any way to set ini_set('max_execution_time', $amountOfTime) in a single common place so that it will impact into whole laravel project?

  • 2
    Just put it where you need it. No reason for having that timeout unless it's necessary for that particular request. It can actually case more harm than good. If you still want to do it, you can set it in index.php or in any of the other files that boots laravel up (haven't used Laravel for years so can't be more specific). Optimizing the code should be the first option though. Fixing the problem is better than just cater to the symptom. – M. Eriksson Jul 19 '23 at 16:12
  • Set the `ini_set` inside **public/index.php** – Sachin Bahukhandi Jul 19 '23 at 16:14
  • You can also use [set_time_limit](https://www.php.net/manual/en/function.set-time-limit.php) which does not affect the php.ini setting. However for your use case I suggest you process your data in a queue (which should be configured to not have a time limit) – apokryfos Jul 19 '23 at 18:33
  • Does this answer your question? [Fatal error: Maximum execution time of 30 seconds exceeded](https://stackoverflow.com/questions/5164930/fatal-error-maximum-execution-time-of-30-seconds-exceeded) – Ram Chander Jul 21 '23 at 06:32

1 Answers1

1

You may do this:

ini_set('max_execution_time', 300);
Wakil Ahmed
  • 1,053
  • 1
  • 8
  • 16