Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sitemap Generator timed out, maximum execution time of 60 seconds exceeded

I need to generate a sitemap.

I am using spatie/laravel-sitemap. I have installed and published it but when I run the generator Symphony throws a fatal error: Maximum execution time of 60 seconds exceeded.

I have a huge list of links and left just one to test, but still getting the same error.

How to fix that? Here is my web.php code:

<?php

use Spatie\Sitemap\SitemapGenerator;

// this link throws a fatal error: Maximum execution time of 60 seconds exceeded
Route::get('sitemap', function(){

    SitemapGenerator::create('127.0.0.1:8000')->writeToFile('sitemap.xml');

    return 'sitemap created';

});

// this link is tested and fully working
Route::get('', function () {
    return view('home');
});
like image 413
Kirill Avatar asked Oct 29 '25 05:10

Kirill


1 Answers

This is a common problem when working with long running scripts.

Did you try using php function set_time_limit ?

Try putting in the beginning of your script

set_time_limit(300);

like image 90
Borko Rastović Avatar answered Oct 30 '25 21:10

Borko Rastović



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!