PHPackages                             werkspot/sitemap-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. werkspot/sitemap-bundle

ActiveSymfony-bundle

werkspot/sitemap-bundle
=======================

Bundle for generating dynamic sitemap.xml content with support for multiple sections

v6.0.0(11mo ago)11182.9k—4%4[2 issues](https://github.com/Werkspot/sitemap-bundle/issues)MITPHPPHP ^8.4CI passing

Since Jul 31Pushed 11mo ago35 watchersCompare

[ Source](https://github.com/Werkspot/sitemap-bundle)[ Packagist](https://packagist.org/packages/werkspot/sitemap-bundle)[ RSS](/packages/werkspot-sitemap-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (22)Used By (0)

Werkspot sitemap bundle
=======================

[](#werkspot-sitemap-bundle)

Bundle for generating dynamic sitemap.xml content with support for multiple sections and pages per section.

[![Travis build status](https://camo.githubusercontent.com/10bb649b95b8e4c4a749f2738ad1f0719969be487be4ec7831d0a831d5b43054/68747470733a2f2f7472617669732d63692e6f72672f5765726b73706f742f736974656d61702d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Werkspot/sitemap-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ae3afc5d475f095e6d72f354f92598315702afaaaaaded6e5a382433a596c276/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5765726b73706f742f736974656d61702d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Werkspot/sitemap-bundle/?branch=master)

### Install

[](#install)

`# composer require werkspot/sitemap-bundle`

#### Update your routing

[](#update-your-routing)

```
werkspot_sitemap:
    resource: "@WerkspotSitemapBundle/Resources/config/routing.yml"
    prefix:   /
```

That will make the bundle listen to `/sitemap.xml`, `/sitemap.{section}.xml` and `/sitemap.{section}.{page}.xml`

### Usage

[](#usage)

The bundle generates a sitemap by looking for data providers.

A provider is a class that implements [ProviderInterface](Provider/ProviderInterface.php) and is tagged as `werkspot.sitemap_provider` in the service container.

The bundle's service will gather data from all providers and create a sitemap section for every one of them.

Each section can generate one or more pages.

#### Single page provider

[](#single-page-provider)

To facilitate sitemap creation for static lists things or pages that do not need to be created dynamically [AbstractSinglePageSitemapProvider](Provider/AbstractSinglePageSitemapProvider.php) can be extended. That will only require providing a section name and a SitemapSectionPage with Url objects.

##### Example

[](#example)

```
namespace AppBundle\Sitemap;

use Werkspot\Bundle\SitemapBundle\Provider\AbstractSinglePageSitemapProvider;
use Werkspot\Bundle\SitemapBundle\Sitemap\SitemapSectionPage;
use Werkspot\Bundle\SitemapBundle\Sitemap\Url;

class StaticPageSitemapProvider extends AbstractSinglePageSitemapProvider
{
    public function getSectionName(): string
    {
        return 'default';
    }

    public function getSinglePage(): SitemapSectionPage
    {
        $page = new SitemapSectionPage();

        $urlRoute = $this->generateUrl('home');
        $page->addUrl(new Url($urlRoute, Url::CHANGEFREQ_WEEKLY, 1.0));

        $urlRoute = $this->generateUrl('some_page');
        $page->addUrl(new Url($urlRoute, Url::CHANGEFREQ_WEEKLY, 0.6));

        $urlRoute = $this->generateUrl('another_page');
        $page->addUrl(new Url($urlRoute, Url::CHANGEFREQ_WEEKLY, 0.6));

        return $page;
    }
}
```

This will generate `/sitemap.default.xml` with 3 pages and put a link to it in `/sitemap.xml`

#### Multiple page provider

[](#multiple-page-provider)

A more complex provider can extend [AbstractSitemapProvider](Provider/AbstractSitemapProvider.php). In that case the provider can select how many pages it wants to generate and what results to return in every page.

##### Example

[](#example-1)

The following will generate `/sitemap.products.xml` and if the count is too high it will split in multiple pages: `/sitemap.products.1.xml`, `/sitemap.products.2.xml` etc and put all the right links to these in `/sitemap.xml` for indexing to happen.

```
namespace AppBundle\Sitemap;

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Werkspot\Bundle\SitemapBundle\Provider\AbstractSitemapProvider;
use Werkspot\Bundle\SitemapBundle\Sitemap\SitemapSectionPage;
use Werkspot\Bundle\SitemapBundle\Sitemap\Url;
use AppBundle\Domain\Entity\Repository\ProductRepository;
use AppBundle\Domain\Entity\Product;

class ProductSitemapProvider extends AbstractSitemapProvider
{
    public function __construct(
        UrlGeneratorInterface $urlGenerator,
        private ProductRepository $productRepository,
    ) {
        parent::__construct($urlGenerator);
    }

    public function getPage(int $pageNumber): SitemapSectionPage
    {
        $products = $this->productRepository->getProductsForSitemapPage(
            $pageNumber,
            $this->getMaxItemsPerPage()
        );

        $page = new SitemapSectionPage();
        foreach ($products as $product) {
            $urlRoute = $this->generateUrl('product_details', [
                'slug' => $product->getSlug()
            ]);
            $page->addUrl(new Url($urlRoute, Url::CHANGEFREQ_MONTHLY, 0.6));
        }

        return $page;
    }

    public function getSectionName(): string
    {
        return 'products';
    }

    public function getCount(): int
    {
        return $this->productRepository->getTotalCount();
    }
}
```

### Adding alternate language pages

[](#adding-alternate-language-pages)

To add links to translations for pages to the sitemap, you can use `AlternateLink` and add these to a Url.

Google Guidelines:

*Note: The alternate links should include the Url itself, see the second note in the link above*

#### Example

[](#example-2)

```
    public function getSinglePage(): SitemapSectionPage
    {
        $page = new SitemapSectionPage();

        $urlRoute = $this->generateUrl('home');
        $urlRouteDe = $this->generateUrl('home', ['_locale' => 'de']);
        $urlRouteFr = $this->generateUrl('home', ['_locale' => 'fr']);

        $sitemapUrl = new Url($urlRoute, Url::CHANGEFREQ_WEEKLY, 1.0);
        $sitemapUrl->addAlternateLink(new AlternateLink($urlRouteDe, 'de'));
        $sitemapUrl->addAlternateLink(new AlternateLink($urlRouteFr, 'fr'));
        $sitemapUrl->addAlternateLink(new AlternateLink($urlRoute, 'x-default')); // Country select page
        // Or
        $sitemapUrl->addAlternateLink(new AlternateLink($urlRoute, 'en'));

        $page->addUrl($sitemapUrl);

        return $page;
    }
```

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance48

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~299 days

Recently: every ~366 days

Total

13

Last Release

348d ago

Major Versions

v1.2.2 → v2.0.02020-02-11

v2.0.0 → v3.0.02020-07-30

v3.0.0 → 4.0.02021-06-01

v4.1.0 → v5.0.02025-04-25

v5.0.0 → v6.0.02025-06-04

PHP version history (7 changes)v1.0.0PHP &gt;=5.4

1.2.0PHP &gt;=5.5

v1.2.2PHP ^7.1

v3.0.0PHP ^7.4

4.0.0PHP ^7.4 || ^8.0

v5.0.0PHP ^8.3

v6.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/37301ff25cf2c512e7c1079160028e6e4c27194b6ba6d44aa52213ba2e3feaac?d=identicon)[jeroenvdheuvel](/maintainers/jeroenvdheuvel)

![](https://www.gravatar.com/avatar/1582e6b6023d34b69760da85219041ab8b376706b86ec03d942d12f946e4a7dc?d=identicon)[EHER](/maintainers/EHER)

![](https://www.gravatar.com/avatar/3adf51640a62af3d5ba00df48b9bcec1d6d55adb8d76eb2a47b1064cda693d1d?d=identicon)[MarijnKoesen](/maintainers/MarijnKoesen)

![](https://www.gravatar.com/avatar/99d3da37dfb742ac4a51091f756f8a632cc9d4a12f433fe3c6a51056808372f6?d=identicon)[werkspot](/maintainers/werkspot)

![](https://www.gravatar.com/avatar/7140a8c7b834b07674c6bd74d6cb75792522ceba17dfb1f347489083a0ba1c48?d=identicon)[malukenho](/maintainers/malukenho)

---

Top Contributors

[![thanosp](https://avatars.githubusercontent.com/u/1217690?v=4)](https://github.com/thanosp "thanosp (19 commits)")[![ruudvanderweijde](https://avatars.githubusercontent.com/u/3205112?v=4)](https://github.com/ruudvanderweijde "ruudvanderweijde (17 commits)")[![MarijnKoesen](https://avatars.githubusercontent.com/u/711208?v=4)](https://github.com/MarijnKoesen "MarijnKoesen (14 commits)")[![abame](https://avatars.githubusercontent.com/u/2082630?v=4)](https://github.com/abame "abame (12 commits)")[![thijsBreker](https://avatars.githubusercontent.com/u/5063394?v=4)](https://github.com/thijsBreker "thijsBreker (6 commits)")[![kvdnberg](https://avatars.githubusercontent.com/u/3639548?v=4)](https://github.com/kvdnberg "kvdnberg (3 commits)")[![prestes](https://avatars.githubusercontent.com/u/399528?v=4)](https://github.com/prestes "prestes (1 commits)")[![ScullWM](https://avatars.githubusercontent.com/u/1017746?v=4)](https://github.com/ScullWM "ScullWM (1 commits)")[![tacman](https://avatars.githubusercontent.com/u/619585?v=4)](https://github.com/tacman "tacman (1 commits)")[![ferrastas](https://avatars.githubusercontent.com/u/116074?v=4)](https://github.com/ferrastas "ferrastas (1 commits)")[![batusa](https://avatars.githubusercontent.com/u/5388003?v=4)](https://github.com/batusa "batusa (1 commits)")

---

Tags

bundlephpsitemapsymfonysymfony-bundlesymfonybundleSitemapseo

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/werkspot-sitemap-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/werkspot-sitemap-bundle/health.svg)](https://phpackages.com/packages/werkspot-sitemap-bundle)
```

###  Alternatives

[presta/sitemap-bundle

A Symfony bundle that provides tools to build your application sitemap.

3929.4M28](/packages/presta-sitemap-bundle)[winzou/state-machine-bundle

Bundle for the very lightweight yet powerful PHP state machine

34010.4M15](/packages/winzou-state-machine-bundle)[pentatrion/vite-bundle

Vite integration for your Symfony app

2755.3M13](/packages/pentatrion-vite-bundle)[florianv/swap-bundle

Integrates the Swap library with Symfony

62416.1k1](/packages/florianv-swap-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
