- Is samdark/sitemap a Laravel package?
- No. samdark/sitemap is a framework-agnostic PHP library for building XML sitemap and sitemap index documents, with optional Yii2 integration. In Laravel you install it with Composer and write a thin adapter for URL discovery, chunking, storage, and routing; there is no service provider, facade, or publishable config. Treat it as an XML builder, not a turnkey Laravel sitemap solution.
- How do I install samdark/sitemap in a Laravel app?
- Run composer require samdark/sitemap and confirm the release supports your PHP version and XML extension baseline. Because it is not Laravel-aware, you do not register a provider or publish config. Wrap the generator in your own service or Artisan command and keep the dependency behind that boundary so it is easy to replace.
- Does samdark/sitemap support sitemap index files?
- The library is described as a sitemap and sitemap index builder, so index generation is part of its intended scope. You still own the Laravel-side logic that splits URLs into chunks and builds the matching child sitemap references. Verify the exact API and limits against the pinned release before production rollout.
- How do I generate and serve a sitemap in Laravel with samdark/sitemap?
- Create an Artisan command that queries canonical URLs with chunkById, maps each row to a sitemap URL entry with lastmod, changefreq, and priority, and passes the collection to the generator. Write the XML to Storage, for example storage/app/public/sitemaps, and serve /sitemap.xml through a route or static file. Reference the sitemap index from robots.txt and schedule regeneration only if your content changes often.
- How do I avoid memory issues with 50,000 sitemap URLs?
- The library renders from an in-memory collection, so the risk sits in how you load data, not in XML serialization alone. Paginate at the database layer with chunkById and emit one child sitemap per chunk, staying within the 50,000 URL and 50MB limits. Never call Model::all(), and keep query strings and non-ASCII paths short where possible.
- Does samdark/sitemap escape XML correctly for query strings and non-ASCII URLs?
- XML escaping is essential for ampersands, encoded characters, and non-ASCII paths, and the technical review notes this must be verified for your pinned release. Test URLs with query parameters, IDN domains, and Unicode slugs before relying on the output. If an edge case is not handled, escape or normalize URLs in your adapter before passing them to the generator.
- Does samdark/sitemap support gzip compression and caching?
- The package overview lists gzip compression and caching among its features, alongside Yii2 integration. In Laravel, gzip output is often handled by your adapter or web server, so confirm whether the library or your wrapper owns that responsibility. Cache generated sitemap files in Storage and regenerate on a schedule rather than rebuilding on every request.
- Does samdark/sitemap support lastmod formatting, changefreq, priority, and hreflang alternates?
- The library builds URL entries, and the technical review flags lastmod formatting to W3C datetime and hreflang xhtml:link support as items to verify. Treat changefreq and priority as optional hints and enforce them in your adapter if the library does not. If hreflang alternates are not first-class, extend your wrapper or emit them carefully rather than forking the package for one feature.
- How do I test sitemap generation in Laravel?
- Unit-test your URL mapping and chunking logic, then assert the generated XML contains expected loc, lastmod, changefreq, and priority values. Include fixture URLs with ampersands, encoded characters, and non-ASCII paths to catch escaping regressions. For integration tests, write to a fake Storage disk and assert the sitemap index references each child sitemap exactly once.
- Is samdark/sitemap maintained, and what are the alternatives?
- It has healthy adoption at roughly 543 stars under a BSD-3 license, but it is effectively single-maintainer; confirm the canonical repository and pin a version before adoption. The sitemap protocol is stable, so low release velocity is acceptable, and the last release date in the review suggests it is current. Alternatives include spatie/laravel-sitemap for a Laravel-native API, or writing a small generator yourself if you need only basic urlset output.