mkebza/sitemap-bundle

Symfony bundle generating sitemaps

Installs: 160

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Open Issues: 0

Type:symfony-bundle

v1.0.1 2019-01-15 02:52 UTC

This package is auto-updated.

Last update: 2020-06-15 06:09:41 UTC


README

Build Status

Instalation

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

$ composer require mkebza/sitemap-bundle

Applications that don't use Symfony Flex

Step 1: Download the Bundle

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

$ composer require mkebza/sitemap-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

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

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new MKebza\Sitemap\MKebzaSitemapBundle(),
        );

        // ...
    }

    // ...
}

Configuration

there is only one available configuration and that is base_url, its automatically prepended to all url if they aren't fully quilified.

m_kebza_sitemap:
    base_url: http://www.example.com

Usage

Collecting routes works by implementing MKebza\Sitemap\Service\SitemapLocationGeneratorInterface which is then autoconfigured via symfony container. If you don't use autoconfiguration, you need to tag your service with mkebza_sitemap.generator tag to be used.

SitemapLocationGeneratorInterface

Has one method generate() which is generator and needs to yield object of MKebza\Sitemap\Service\Location.

Location

You can either use absolute url or relative URL, which will be prepended by url set in your configuration.

Generating sitemap

From your terminal run bin/console sitemap:generate, default path is public/sitemap.xml, but you can change it by passig path as first argument to the command.

You need to put this command to you cron / scheduler to generate sitemap on regular basis.