A very flexible PHP sitemap generator library to suit all your sitemap needs

Sitemap PHP Sitemap Generator

Dynamic Sitemaps

If you wanted to, you can have a sitemap route, without having the file itself written. This is called Dynamic Sitemaps, wherein the sitemaps are treated as a page in the application but it outputs an XML (or any other format) instead of the usual HTML.

use Alexecus\Sitemaper\Sitemap;

// Create sitemap and add items to it

$sitemap = new Sitemap('', [

// We want to fetch the raw XML so we call the transform method, we are asking
// Sitemaper to give as the transformed sitemap

$rawXml = $sitemap->transform('xml');

// Do whatever you want with the raw output
// let's echo it for example

echo $rawXml;

// or if you are using a framework that uses PSR-7

$response = $response->withBody($rawXml);