1. Go to this page and download the library: Download initbiz/sitemap library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
initbiz / sitemap example snippets
$url1 = new UrlDOMElement();
$url1->setLoc('https://www.example.com/foo.html');
$url1->setLastmod('2022-06-04');
$url1->setPriority('1.0');
$url1->setChangefreq('always');
$url2 = new UrlDOMElement();
$url2->setLoc('https://www.example.com/foo2.html');
$url2->setLastmod('2022-06-04');
$url2->setPriority('0.9');
$urlSetDOMElement = new UrlsetDOMElement();
$urlSetDOMElement->setUrls([$url1, $url2]);
$DOMElements = [$urlSetDOMElement];
$generator = new BasicGenerator();
$generator->setDOMElements($DOMElements);
$xml = $generator->generate();
$url1 = new UrlDOMElement();
$url1->setloc('https://example.com/sample1.html');
$image = new ImageDOMElement();
$image->setLoc('https://example.com/image.jpg');
$photo = new ImageDOMElement();
$photo->setLoc('https://example.com/photo.jpg');
$url1->setImages([$image, $photo]);
$url2 = new UrlDOMElement();
$url2->setloc('https://example.com/sample2.html');
$picture = new ImageDOMElement();
$picture->setLoc('https://example.com/picture.jpg');
$url2->setImages([$picture]);
$urlSetDOMElement = new UrlsetDOMElement();
$urlSetDOMElement->setUrls([$url1, $url2]);
$DOMElements = [$urlSetDOMElement];
$generator = new BasicGenerator();
$generator->setDOMElements($DOMElements);
$sitemap1 = new SitemapDOMElement();
$sitemap1->setLoc('https://www.example.com/sitemap1.xml.gz');
$sitemap2 = new SitemapDOMElement();
$sitemap2->setLoc('https://www.example.com/sitemap2.xml.gz');
$sitemapIndexDOMElement = new SitemapIndexDOMElement();
$sitemapIndexDOMElement->setSitemaps([$sitemap1, $sitemap2]);
$DOMElements = [$sitemapIndexDOMElement];
$generator = new BasicGenerator();
$generator->setDOMElements($DOMElements);
$xml = $generator->generate();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.