Skip to content
This repository was archived by the owner on Sep 17, 2018. It is now read-only.
Mario Basic edited this page Mar 31, 2015 · 12 revisions

Framework agnostic approach

Creating a Sitemap

use Laravelista\Bard\UrlSet as Sitemap;
use Sabre\Xml\Writer;
use Carbon\Carbon;

$sitemap = new Sitemap(new Writer);

$home = $sitemap->addUrl('http://acme.me');
$home->setPriority(0.8);
$home->setChangeFrequency('hourly');
$home->setLastModification(Carbon::now());
$home->addTranslation("de", 'http://acme.me/de/contact');*/

$sitemap->addUrl(
    'http://acme.me/contact', 
    0.5, 
    null, 
    new DateTime('2015-04-01'), 
    [
        [
            "hreflang" => 'de', 
            'href' => 'http://acme.me/de/contact'
        ]
    ]
);

$sitemap->addUrl('http://acme.me/gallery');

return $sitemap->render();
Clone this wiki locally