spatie/laravel-sitemap
Generate XML sitemaps for Laravel by crawling your site or building them manually. Add extra URLs, set last-modified dates, and include models via a simple interface. Write sitemaps to disk with a fluent, developer-friendly API.
You can create a sitemap entirely by hand, without crawling:
use Carbon\Carbon;
use Spatie\Sitemap\Sitemap;
use Spatie\Sitemap\Tags\Url;
Sitemap::create()
->add('/page1')
->add('/page2')
->add(Url::create('/page3')->setLastModificationDate(Carbon::create('2016', '1', '1')))
->writeToFile($sitemapPath);
You can check if the sitemap contains a specific URL and retrieve it:
$sitemap->hasUrl('/page2'); // returns true or false
$sitemap->getUrl('/page2'); // returns a Url object or null
How can I help you explore Laravel packages today?