PHP code example of asika / sitemap
1. Go to this page and download the library: Download asika/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/ */
asika / sitemap example snippets
use Asika\Sitemap\Sitemap;
$sitemap = new Sitemap();
$sitemap->addItem($url);
$sitemap->addItem($url);
$sitemap->addItem($url);
use Asika\Sitemap\ChangeFreq;
$sitemap->addItem($url, '1.0', ChangeFreq::DAILY, '2015-06-07 10:51:20');
$sitemap->addItem($url, '0.7', ChangeFreq::WEEKLY, new \DateTime('2015-06-03 11:24:20'));
echo $sitemap->render();
// OR
(string) $sitemap;
$sitemap->save('/path/to/sitemap.xml');
// OR
$file = new SplFileInfo('/path/to/sitemap.xml');
$sitemap->save($file);
header('Content-Type: application/xml');
echo $sitemap;
exit();
$sitemap->output();
exit();
$response = new Response();
$response = $sitemap->handleResponse($response);
return $response;
$sitemap->setAutoEscape(false);
ChangeFreq::ALWAYS;
ChangeFreq::HOURLY;
ChangeFreq::DAILY;
ChangeFreq::WEEKLY;
ChangeFreq::MONTHLY;
ChangeFreq::YEARLY;
ChangeFreq::NEVER;
$sitemap->setDateFormat(\DateTimeInterface::ISO8601);
// OR
$sitemap->setDateFormat('Y-m-d');
$sitemap = new \Asika\Sitemap\NewsSitemap();
$sitemap->addItem(
$url,
$newsTitle,
'Publication Name',
'en-us',
$publishedDate
);
use Asika\Sitemap\SitemapIndex;
$index = new SitemapIndex();
$index->addItem('http://domain.com/sitemap1.xml', $lastmod1);
$index->addItem('http://domain.com/sitemap2.xml', $lastmod2);
echo $index->render();