I am downloading a JSON file from an online source and and when it runs through the loop I am getting this error:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\temp\fetch.php on line 24
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Optimize your code
You need to optimize your code and look for errors.
For example, you could mistakenly create an endless loop. Obviously, in this case increasing the execution time won’t help.
Or, given you are storing the received data in the database, there are techniques that can greatly improve the performance, such as using transactions or multi-insert queries.
Profile your code, find performance bottlenecks and optimize them.
Run as CLI
In case the code is already optimized but inevitably takes too much time, consider execute it not as a web-page call but as a command line script. When called from a command line, PHP scripts aren’t affected by the time limit.
For example, you can configure this JSON download as a cron job, or implement some queue, when your web-page only creates a job, that takes a fraction of second, while some background process will take time to download, parse and store your JSON.
Increase the time limit
As a last resort you could temporarily extend the time limit, using either
or