library sitemaped
PHP Sitemap abstraction library
trntv/sitemaped
PHP Sitemap abstraction library
- Sunday, May 6, 2018
- by trntv
- Repository
- 1 Watchers
- 0 Stars
- 559 Installations
- PHP
- 2 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 239 % Grown
# PHP Sitemap abstraction library
-
Add urls one-by-one, (*1)
$urlset = new Urlset($links);
foreach(range('a', 'z') as $letter) {
$url = new Url(
'https://vocabula.ry/'.$letter,
new \DateTime('2017-01-01 00:00:01'),
Url::CHANGEFREQ_MONTHLY,
0.8
);
$url->addImage(new Image('https://test.com/image/'.$i));
$url->addVideo(new Video('https://test.com/video/'.$i, 'Title '.$i, 'Description '.$i));
$url->addNews(new News('Awesome news '.$i, '2018-01-01', 'Awesome news name '.$i, 'ru-RU'));
$urlset->addUrl($url);
}
$sitemap = new Sitemap($urlset);
$sitemap->toXmlString();
$sitemap->toTxtString();
$sitemap->write(__DIR__ . '/sitemap.xml');
$sitemap->write(__DIR__ . '/sitemap.txt', Sitemap::FORMAT_TXT);
-
Using links generator, (*2)
$links = function() {
foreach(range('a', 'z') as $letter) {
$url = new Url(
'https://vocabula.ry/'.$letter,
new \DateTime('2017-01-01 00:00:01'),
Url::CHANGEFREQ_MONTHLY,
0.8
);
$url->addImage(new Image('https://test.com/image/'.$i));
$url->addVideo(new Video('https://test.com/video/'.$i, 'Title '.$i, 'Description '.$i));
$url->addNews(new News('Awesome news '.$i, '2018-01-01', 'Awesome news name '.$i, 'ru-RU'));
yield $url;
}
}
$urlset = new Urlset($links);
$sitemap = new Sitemap($urlset);
$sitemap->toXmlString();
$sitemap->toTxtString();
$sitemap->write(__DIR__ . '/sitemap.xml');
$sitemap->write(__DIR__ . '/sitemap.txt', Sitemap::FORMAT_TXT);
-
Sitemap index, (*3)
$index = new Sitemapindex();
$sitemap = new Sitemap($index);
foreach (range(1, 2) as $i) {
$sitemap = new SitemapindexSitemap(
'http://test.com/'.$i,
'-1 year'
);
$index->addSitemap($sitemap);
}
$content = $sitemap->toXmlString();
dev-master
9999999-dev
PHP Sitemap abstraction library
Sources
Download
MIT
The Requires
The Development Requires
0.1.1
0.1.1.0
PHP Sitemap abstraction library
Sources
Download
MIT
The Requires
The Development Requires
0.1.0
0.1.0.0
PHP Sitemap abstraction library
Sources
Download
MIT
The Requires
The Development Requires