arkdevuk/sitemap-builder

easy hand on sitemap builder for SEO purposes written in php

1.0.2 2021-06-22 18:05 UTC

This package is auto-updated.

Last update: 2024-10-23 18:31:54 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License Made With

Sitemap-build

a simple tool to generate sitemaps for google's bots

USAGE

as simple as this :

<?php

namespace App;


require_once __DIR__ . '/../vendor/autoload.php';

use ArkdevukSitemapBuilder\classes\Sitemap;
use ArkdevukSitemapBuilder\classes\SitemapContainer;
use ArkdevukSitemapBuilder\classes\SitemapEntry;
use ArkdevukSitemapBuilder\classes\SitemapEntryImage;

$baseUrl = 'https://mywebsite.tld';

$container = new SitemapContainer($baseUrl, __DIR__.DIRECTORY_SEPARATOR.'example1');

$sitemap = new Sitemap('page');

$entry = new SitemapEntry();
$entry
    ->setLocation('/test')
    ->setChangeFrequency(SitemapEntry::CHANGE_WEEKLY)
    ->setPriority(1)
    ->setLastModDateTime(new \DateTime('2020-12-10'));

$media = new SitemapEntryImage($baseUrl.'/assets/images/image.jpeg');
$media
    ->setCaption('A test image for the purpose of the example')
    ->setGeoLocation('Aurillac, Cantal, France')
    ->setTitle('Image Title')//->setLicence('https://creativecommons.org/licenses/by-nc-nd/4.0/')
;

$entry->setMedia($media);

$sitemap->addEntry($entry);

$container->addSitemap($sitemap);


$container->compile();