PrestaSitemapBundle is a Symfony2 xml sitemap generator.
💬 If you want to have some informations about the projet progression you can register to our google group
For a ready to use demonstration of PrestaSitemap you should check the prestacms-sandox available on github.
Sandbox is also deployed for a live demonstration :
- See also the
require
section of composer.json
- Sitemapindex
- Google images, video, mobile and multilang urls
- Respect constraints (50k items / 10mB per files)
- No database required
- Optionnal caching (using DoctrineCacheBundle, disabled by default)
-
Installation
composer require presta/sitemap-bundle
//app/AppKernel.php public function registerBundles() { $bundles = array( //... new Presta\SitemapBundle\PrestaSitemapBundle(), ); }
#app/config/routing.yml PrestaSitemapBundle: resource: "@PrestaSitemapBundle/Resources/config/routing.yml" prefix: /
-
Usage
For static url there's annotation support in your routes :
/** * @Route("/", name="homepage", options={"sitemap" = true}) */
Or YAML support:
homepage: path: / defaults: { _controller: "AppBundle:Default:index" } options: sitemap: true
Or XML support:
<route id="homepage" path="/"> <default key="_controller">AppBundle:Default:index</default> <option key="sitemap">true</option> </route>
For complexe routes, create a Closure or a Service dedicated to your sitemap then add your urls :
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; // ... function(SitemapPopulateEvent $event) use ($router){ //get absolute homepage url $url = $router->generate('homepage', array(), UrlGeneratorInterface::ABSOLUTE_URL); //add homepage url to the urlset named default $event->getUrlContainer()->addUrl( new UrlConcrete( $url, new \DateTime(), UrlConcrete::CHANGEFREQ_HOURLY, 1 ), 'default' ); }
-
Decorated url (images, videos, etc.)
The doc is already really short ;)
You will find the detailed documentation in the following links :
- 1-Installation.md
- 2-Configuration.md
- 3-Usage-Quick_and_dirty.md
- 4-Usage-Routing_Config.md
- 5-Usage-Event_Listener.md
- 6-Url_Decorator.md
- 7-Dumper_command.md
- CHANGELOG.md
- CONTRIBUTORS.md
💬 If you need help about this project you can post a message on our google group
Pull requests are welcome.
Thanks to everyone who has contributed already.
This project is supported by PrestaConcept
Lead Developer : @nicolas-bastien
Released under the MIT License