- How do I install laravelium/sitemap in a Laravel application?
- Install it with Composer using composer require laravelium/sitemap, then publish the package configuration if you need to customize defaults. The package integrates through a Laravel facade, config file, and Artisan commands, so you can register URL sources and generate sitemap files from the console or a scheduled job. Pin the dependency to version 1.0.4 or higher so you get the Sitemap::store path traversal fix.
- Which Laravel versions does laravelium/sitemap support?
- The package ships a Laravel adapter and facade built on a framework-agnostic PHP core, so it works across modern Laravel releases that satisfy the Composer constraints in its composer.json. Always check those constraints before upgrading Laravel, since the adapter is what binds Eloquent models, routes, and the service container. If you are on an older Laravel version, verify compatibility first or use the core library directly.
- How do I generate sitemap URLs from Eloquent models, routes, or an API?
- Use the Laravel adapter or write a custom adapter that returns URLs from Eloquent queries, route lists, API resources, or any custom source, then register it in a service provider. Adapters keep URL sourcing decoupled from your business logic, which makes the sitemap easier to test and change. Watch for N+1 queries when generating URLs from relationships, and eager load or chunk your data to keep generation fast.
- Can laravelium/sitemap include images, videos, translations, and Google News metadata?
- Yes. The package supports image and video entries, multilingual xhtml:link alternates for hreflang, and Google News sitemaps alongside standard XML, TXT, and HTML output. You set lastmod, changefreq, and priority per URL through the fluent API. Validate the generated output against Google Search Console, since incorrect hreflang or News metadata can hurt crawling rather than help it.
- How do I handle large sites with more than 50,000 URLs?
- Above roughly 50,000 URLs per file you should split output using sitemap indexing and generate multiple child sitemaps instead of one large file. The package supports batch and chunking behavior so you do not need to hold every URL in memory at once. For very large or highly dynamic sites, combine chunked generation with queued jobs and a sitemap index at a stable public URL.
- Does laravelium/sitemap cache sitemaps automatically?
- No. There is no built-in caching layer, so you need to add caching yourself through Laravel's cache, Redis, a CDN, or by writing static sitemap files to disk. A common pattern is to generate sitemaps on a schedule and serve the stored files rather than regenerating on every request. That keeps response times low and avoids expensive queries during crawler traffic.
- How do I keep my Laravel sitemap updated automatically?
- Sitemaps are not real-time by default, so regeneration must be triggered by a scheduled Artisan command, a model event, or a queued job. For most applications a nightly or hourly scheduled job that rebuilds and stores the sitemap is sufficient. For frequently changing content, dispatch regeneration after publish or update events and monitor for failures.
- Is laravelium/sitemap affected by the Sitemap::store path traversal vulnerability?
- Versions before 1.0.4 allowed path traversal through filenames passed to Sitemap::store, so you should pin the dependency to 1.0.4 or later and upgrade as a high priority if any code passes a filename to that method. Even after upgrading, avoid deriving sitemap filenames from request data, tenant input, CMS content, or admin configuration, and keep storage paths constrained. If sitemaps live under the public web root, review filename handling and public exposure carefully.
- Can I use laravelium/sitemap outside Laravel, for example with Symfony or plain PHP?
- Yes. The underlying php-sitemap core is framework-agnostic and works in Symfony or any PHP 8.2+ project, while the laravelium/sitemap adapter adds Laravel-specific conveniences such as the facade, config publishing, and Artisan commands. Laravel-only features like route and Eloquent helpers require the adapter. In non-Laravel projects you build URLs explicitly or through your own adapters.
- What are the alternatives to laravelium/sitemap for Laravel sitemap generation?
- Spatie's laravel-sitemap and similar packages are common alternatives, and the same author maintains npm-sitemap and go-sitemap with a matching API if you need consistency across languages. laravelium/sitemap is a strong fit when you want multiple output formats, image, video, and hreflang support, and a framework-agnostic core you can reuse outside Laravel. Compare on caching behavior, chunking support, and how actively maintained each option is before committing.