kbsali / sitemap-serializer
A simple way to generate sitemaps using Symfony2's Serializer Component
dev-master
2013-04-12 09:58 UTC
Requires
- symfony/serializer: 2.2.*
This package is auto-updated.
Last update: 2024-12-04 20:35:47 UTC
README
A simple PHP5 library to generate Sitemaps base on Symfony2 Serializer Component. The original idea comes from Exemple d'utilisation du composant serializer de Symfony2: création d'un sitemap by metalmumu.
Usage
Add dependency to your project
php composer.phar require kbsali/sitemap-serializer
Sample usage
<?php require_once __DIR__.'/vendor/autoload.php'; use Sitemap\Sitemap; $s = new Sitemap; $s->addItem('http://example.com'); $s->addItem('http://example.com/123', '0.2'); $s->addItem('http://example.com/234', .5, '2013-03-12'); $s->addItem('http://example.com/345', .7, date('Y-m-d'), 'always'); die($s);
TODO :
- Ignore empty elements ( see
Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer::setIgnoredAttributes()
) - Add missing attribute
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
in urlset root node (seeSymfony\Component\Serializer\Encoder\XmlEncoder::__construct()
) - Add an optional to output formatted XML (http://php.net/manual/en/domdocument.savexml.php ->
$doc->formatOutput = true;
)