erivello / PrestaSitemapBundle

A symfony 2 bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PrestaSitemapBundle

Build Status

PrestaSitemapBundle on Knpbundles

Introduction

What PrestaSitemapBundle can do for you. The main goal is generate easily your sitemap.xml with several features you may need:

  • sitemapindex
  • google images, video, mobile and multilang urls
  • respect constraints (50k items / 10mB per files)
  • no database required
  • optionnal caching (using LiipDoctrineCacheBundle, disabled by default)

TL;DR

  1. Installation

        //composer.json
        "require": { 
            //...
            "presta/sitemap-bundle": "dev-master"
        }
        //app/AppKernel.php
        public function registerBundles()
        {
            $bundles = array(
                //...
                new Presta\SitemapBundle\PrestaSitemapBundle(),
            );
        }
    #app/config/routing.yml
    PrestaSitemapBundle:
        resource: "@PrestaSitemapBundle/Resources/config/routing.yml"
        prefix:   /
  2. Usage

    For static url there's annotation support in your routes :

    /**
     * @Route("/", name="homepage", options={"sitemap" = true})
     */

    For complexe routes, create a Closure or a Service dedicated to your sitemap then add your urls :

        function(SitemapPopulateEvent $event) use ($router){
            //get absolute homepage url
            $url = $router->generate('homepage', array(), true);
    
            //add homepage url to the urlset named default
            $event->getGenerator()->addUrl(
                new UrlConcrete(
                    $url, 
                    new \DateTime(), 
                    UrlConcrete::CHANGEFREQ_HOURLY, 
                    1
                ),
                'default'
            );
        }
  3. Decorated url (images, videos, etc.)

    The doc is already really short ;)

Full Documentation

You will find the detailed documentation in the following links :

About

A symfony 2 bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.

License:MIT License


Languages

Language:PHP 100.0%