Sitemap生成器超时,超过60秒的最大执行时间

问题描述 投票:0回答:1

我需要生成一个站点地图。

我正在使用spatie/laravel-sitemap。我已经安装并发布了它,但是当我运行生成器时,Symphony会抛出一个致命的错误:Maximum execution time of 60 seconds exceeded

我有一个巨大的链接列表,只留下一个测试,但仍然得到相同的错误。

如何解决?这是我的web.php代码:

<?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');
});
php laravel sitemap spatie
1个回答
1
投票

使用长时间运行的脚本时,这是一个常见问题。

你尝试过使用php功能set_time_limit吗?

尝试放入脚本的开头

set_time_limit(300);

© www.soinside.com 2019 - 2024. All rights reserved.