Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
103 lines (72 sloc) 3.27 KB

SitemapBundle

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Build Status Scrutinizer Code Quality Code Climate Coverage Status

This bundle provides some classes for an automatic sitemap.xml generation.

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

composer require core23/sitemap-bundle

Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    Core23\SitemapBundle\Core23SitemapBundle::class => ['all' => true],
];

Configure the Bundle

Create a configuration file called core23_sitemap.yaml:

# config/routes/core23_sitemap.yaml

core23_sitemap:
    resource: '@Core23SitemapBundle/Resources/config/routing/sitemap.yml'
    prefix: /

Caching

If you want to use caching, you need to add the caching bundle:

composer require cache/cache-bundle
composer require cache/doctrine-adapter # If you want a doctrine cache

Create a configuration file called core23_sitemap.yaml:

# config/packages/core23_sitemap.yaml

core23_sitemap:
    cache:
        service: 'cache.provider.sitemap_cache'

cache_adapter:
    providers:
        sitemap_cache:
            factory: 'cache.factory.doctrine_filesystem'
            options:
                directory: '%kernel.cache_dir%/cache'

Add static entries

You can add static entries in your yaml config:

# config/packages/core23_sitemap.yaml

core23_sitemap:
    static:
        - { url: 'http://example.com', priority: 75, changefreq: 'weekly' }

Add a custom sitemap

If you want to create a custom sitemap, the only thing you have to do is to create a service that uses Core23\SitemapBundle\Sitemap\SitemapServiceInterface and tag the service with core23.sitemap.

    <service id="App\Sitemap\CustomSitemap">
      <tag name="core23.sitemap"/>
    </service>

License

This bundle is under the MIT license.

You can’t perform that action at this time.