PHPackages                             katech91/yii2-sitemap-module - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. katech91/yii2-sitemap-module

ActiveYii2-extension[Parsing &amp; Serialization](/categories/parsing)

katech91/yii2-sitemap-module
============================

Yii2 module for automatically generation XML Sitemap

1.2.0(9y ago)23331MITPHP

Since Sep 29Pushed 9y ago2 watchersCompare

[ Source](https://github.com/katech91/yii2-sitemap-module)[ Packagist](https://packagist.org/packages/katech91/yii2-sitemap-module)[ RSS](/packages/katech91-yii2-sitemap-module/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

XML Sitemap Module for Yii2
===========================

[](#xml-sitemap-module-for-yii2)

Yii2 module for automatically generating [XML Sitemap](http://www.sitemaps.org/protocol.html).

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

- Either run

```
php composer.phar require --prefer-dist "katech91/yii2-sitemap-module" "*"

```

or add

```
"katech91/yii2-sitemap-module" : "*"
```

to the `require` section of your application's `composer.json` file.

- Configure the `cache` component of your application's configuration file, for example:

```
'components' => [
    'cache' => [
        'class' => 'yii\caching\FileCache',
    ],
]
```

- Add a new module in `modules` section of your application's configuration file, for example:

```
'modules' => [
    'sitemap' => [
        'class' => 'katech91\sitemap\Sitemap',
        'models' => [
            // your models
            'news' => 'app\modules\news\models\News',
            // or configuration for creating a behavior
            'news' => [
                'class' => 'app\modules\news\models\News',
                'behaviors' => [
					'sitemap' => [
						'class' => SitemapBehavior::className(),
						'scope' => function ($model) {
						    /** @var \yii\db\ActiveQuery $model */
						    $model->select(['url', 'lastmod']);
						    $model->andWhere(['is_deleted' => 0]);
						},
						'dataClosure' => function ($model) {
						    /** @var self $model */
						    return [
						        'loc' => Url::to($model->url, true),
						        'lastmod' => strtotime($model->lastmod),
						        'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
						        'priority' => 0.8
						    ];
						}
					],
                ],
            ],
        ],
        'urls'=> [
            // your additional urls
            [
                'loc' => '/news/index',
                'changefreq' => \katech91\sitemap\behaviors\SitemapBehavior::CHANGEFREQ_DAILY,
                'priority' => 0.8,
                'news' => [
                    'publication'   => [
                        'name'          => 'Example Blog',
                        'language'      => 'en',
                    ],
                    'access'            => 'Subscription',
                    'genres'            => 'Blog, UserGenerated',
                    'publication_date'  => 'YYYY-MM-DDThh:mm:ssTZD',
                    'title'             => 'Example Title',
                    'keywords'          => 'example, keywords, comma-separated',
                    'stock_tickers'     => 'NASDAQ:A, NASDAQ:B',
                ],
                'images' => [
                    [
                        'loc'           => 'http://example.com/image.jpg',
                        'caption'       => 'This is an example of a caption of an image',
                        'geo_location'  => 'City, State',
                        'title'         => 'Example image',
                        'license'       => 'http://example.com/license',
                    ],
                ],
            ],
        ],
        'enableGzip' => true, // default is false
        'cacheExpire' => 1, // 1 second. Default is 24 hours
    ],
],
```

- Add behavior in the AR models, for example:

```
use katech91\sitemap\behaviors\SitemapBehavior;

public function behaviors()
{
    return [
        'sitemap' => [
            'class' => SitemapBehavior::className(),
            'scope' => function ($model) {
                /** @var \yii\db\ActiveQuery $model */
                $model->select(['url', 'lastmod']);
                $model->andWhere(['is_deleted' => 0]);
            },
            'dataClosure' => function ($model) {
                /** @var self $model */
                return [
                    'loc' => Url::to($model->url, true),
                    'lastmod' => strtotime($model->lastmod),
                    'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
                    'priority' => 0.8
                ];
            }
        ],
    ];
}
```

- Add a new rules for `urlManager` of your application's configuration file, for example:

```
'urlManager' => [
    'rules' => [
        ['pattern' => 'sitemap', 'route' => 'sitemap/default/sitemap-index', 'suffix' => '.xml'],
        [
            'pattern' => 'sitemap_',
            'route' => 'sitemap/default/sitemap',
            'defaults' => [
                'delimetr' => null,
                'page' => null
            ],
            'suffix' => '.xml',
        ]
    ],
],
```

- Sitemap creates by following scheme: sitemap.xml containes SitemapIndex with list of local sitemaps and url's sitemap:

```

        http://localhost/sitemap_urls.xml

        http://localhost/sitemap_news.xml

```

local sitemaps (for example sitemap\_news.xml) contains addresses of news if number of articles is less than 1 000:

```

        http://localhost/news/first
        2016-01-01T00:00:00+00:00
        daily
        0.8

        http://localhost/news/second
        2016-01-11T00:00:00+00:00
        daily
        0.8

```

If number of articles bigger local sitemap contains addresses of subsitemaps:

```

            http://localhost/sitemap_news_0.xml

            http://localhost/sitemap_news_1.xml

            http://localhost/sitemap_news_2.xml

```

Resources
---------

[](#resources)

- [XML Sitemap](http://www.sitemaps.org/protocol.html)
- [News Sitemap](https://support.google.com/news/publisher/answer/74288?hl=en)
- [Image sitemaps](https://support.google.com/webmasters/answer/178636?hl=en)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 59.4% of commits — single point of failure

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 ~249 days

Total

4

Last Release

3494d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/904e33e1ebe0ce6777484acc001312d97f5782f4507fb7c0cf93cc39ff8c9ce7?d=identicon)[katech91](/maintainers/katech91)

---

Top Contributors

[![himiklab](https://avatars.githubusercontent.com/u/6266409?v=4)](https://github.com/himiklab "himiklab (19 commits)")[![katech91](https://avatars.githubusercontent.com/u/16520024?v=4)](https://github.com/katech91 "katech91 (10 commits)")[![ladamalina](https://avatars.githubusercontent.com/u/2093425?v=4)](https://github.com/ladamalina "ladamalina (2 commits)")[![chuprik](https://avatars.githubusercontent.com/u/802946?v=4)](https://github.com/chuprik "chuprik (1 commits)")

---

Tags

xmlyii2moduleSitemap

### Embed Badge

![Health badge](/badges/katech91-yii2-sitemap-module/health.svg)

```
[![Health](https://phpackages.com/badges/katech91-yii2-sitemap-module/health.svg)](https://phpackages.com/packages/katech91-yii2-sitemap-module)
```

###  Alternatives

[presta/sitemap-bundle

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

3929.4M28](/packages/presta-sitemap-bundle)[demi/sitemap-generator

Yii2 component for generate sitemap.xml files.

1427.0k](/packages/demi-sitemap-generator)[light/yii2-xmlparser

yii2 xml request parser

1974.7k](/packages/light-yii2-xmlparser)

PHPackages © 2026

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