Laravel Sitemap Generation Block?
0
I'm encountering a significant technical block with dynamic sitemap generation in Laravel for datasets exceeding 50,000 URLs. Attempts to resolve this by increasing
memory_limit and max_execution_time consistently result in timeouts or memory exhaustion when building the sitemap. For example, my current process:use App\Models\Url;
use Spatie\Sitemap\SitemapGenerator;
use Spatie\Sitemap\Tags\Url as SitemapUrl;
// This often fails for large datasets
SitemapGenerator::create(config('app.url'))
->hasUrls(Url::all()->map(function (Url $url) {
return SitemapUrl::create($url->path);
}))
->writeToFile(public_path('sitemap.xml'));
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8192 bytes) in /vendor/spatie/laravel-sitemap/src/SitemapGenerator.php on line 123What are the most scalable strategies for large-scale Laravel sitemap generation without external services, considering chunking or alternative builders?0 Answers
No answers yet.
Be the first to provide a helpful answer!
Your Answer
You must Log In to post an answer and earn reputation.