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.
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:
-
Register the bundle in
config/bundles.php:Mmd\SyliusSitemapPlugin\MmdSyliusSitemapPlugin::class => ['all' => true], -
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" -
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:
- It runs only this plugin's open migrations (it creates the table
mmd_sylius_sitemap_channel_settings), nothing from the app or other plugins. - It is idempotent: without a new migration nothing happens, so it is safe after every
composer update. - It checks that the admin and shop routes are imported and prints the snippet if they are not. It never writes to
config/. - If migrations from Sylius itself are still open, it stops and asks you to run
bin/console doctrine:migrations:migratefirst. - It asks for confirmation before running. In scripts, pass
--no-interaction.
Running doctrine:migrations:migrate yourself achieves the same.
Update
composer update mmd/sylius-sitemap-pluginbin/console mmd:sitemap:setup(without a new migration nothing happens)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_dirhas to survive deployments, be writable by the user running the command and readable by the web server user. Ifvar/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:
-
Roll back the migration:
bin/console doctrine:migrations:execute --down 'Mmd\SyliusSitemapPlugin\Migrations\Version20261001100000' -
Remove the routes file
config/routes/mmd_sylius_sitemap.yamland the entry inconfig/bundles.php. -
composer remove mmd/sylius-sitemap-plugin -
Optionally delete the
storage_dirdirectory (defaultvar/sitemap).
Rolling back deletes the settings of all channels. The generated XML files stay in the file system until you remove them.