Markus Michalski FAQ

XML Sitemap: Installation and Operation

Installing the XML sitemap for Sylius 2 via Packeton: bundle and routes, setup command, update, cron job for regular generation, storage directory and uninstallation.

Deutsche Version

Back to overview

XML Sitemap: Installation and Operation

This documentation always describes the latest published version.

Prerequisites

Sylius ^2.2, PHP ^8.3 with ext-xmlwriter, Symfony ^7.4 and MySQL 8 or MariaDB. The full list is in the overview.

Installation

Composer (Packeton)

The plugin lives in a private repository served through Packeton (https://packeton.markus-michalski.net). You receive the credentials after purchasing the license.

Add the repository to your shop's composer.json:

{ "repositories": [{ "type": "composer", "url": "https://packeton.markus-michalski.net" }] }

Install the package:

composer require mmd/sylius-sitemap-plugin

Then, in this order:

  1. Register the bundle in config/bundles.php:

    Mmd\SyliusSitemapPlugin\MmdSyliusSitemapPlugin::class => ['all' => true],
    
  2. Import the routes in config/routes/mmd_sylius_sitemap.yaml:

    mmd_sylius_sitemap_admin:
        resource: "@MmdSyliusSitemapPlugin/config/routes/admin.yaml"
    
    mmd_sylius_sitemap_shop:
        resource: "@MmdSyliusSitemapPlugin/config/routes/shop.yaml"
    
  3. Run the setup command:

    bin/console mmd:sitemap:setup
    

Import the shop routes at the top level, not under the /{_locale} prefix of the Sylius shop routes. Crawlers request the sitemap at the root of the host.

The bundle registers the admin grid, the Twig hooks and the Doctrine mapping itself, so no further configuration is needed.

The setup command

bin/console mmd:sitemap:setup replaces doctrine:migrations:migrate:

Running doctrine:migrations:migrate yourself achieves the same.

Update

  1. composer update mmd/sylius-sitemap-plugin
  2. bin/console mmd:sitemap:setup (without a new migration nothing happens)
  3. bin/console cache:clear

Generating regularly

The sitemap is not rebuilt on every catalog change. Run the command periodically, for example daily:

15 3 * * * cd /var/www/shop && bin/console mmd:sitemap:generate

Containers without a cron daemon start the command from a sleep loop under supervisord instead.

The storage directory storage_dir has to survive deployments, be writable by the user running the command and readable by the web server user. If var/ is recreated on every deploy, mount the directory persistently or generate right after the deploy.

Uninstallation

Keep this order while the bundle is still registered:

  1. Roll back the migration:

    bin/console doctrine:migrations:execute --down 'Mmd\SyliusSitemapPlugin\Migrations\Version20261001100000'
    
  2. Remove the routes file config/routes/mmd_sylius_sitemap.yaml and the entry in config/bundles.php.

  3. composer remove mmd/sylius-sitemap-plugin

  4. Optionally delete the storage_dir directory (default var/sitemap).

Rolling back deletes the settings of all channels. The generated XML files stay in the file system until you remove them.