PHPackages                             himiklab/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. himiklab/yii2-sitemap-module

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

himiklab/yii2-sitemap-module
============================

Yii2 module for automatically generation XML Sitemap

1.2.1(7y ago)90189.1k↑19.1%426MITPHP

Since Sep 29Pushed 7y ago11 watchersCompare

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

READMEChangelog (4)Dependencies (1)Versions (5)Used By (6)

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

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

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

![Packagist](https://camo.githubusercontent.com/07bc238a7d5ca2fb63dae8cade60bec933bd627f881e5dd222b13dc51c358cdb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68696d696b6c61622f796969322d736974656d61702d6d6f64756c652e737667) ![Packagist](https://camo.githubusercontent.com/7fcbd03148babfbbf3cb454702a51a7e71c713a1e18c25ce7c07cf42be075689/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68696d696b6c61622f796969322d736974656d61702d6d6f64756c652e737667) ![license](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)

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

[](#installation)

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

- Either run

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

```

or add

```
"himiklab/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 `use himiklab\sitemap\behaviors\SitemapBehavior;` to the beginning of configuration file
- Add a new module in `modules` section of your application's configuration file, for example:

```
'modules' => [
    'sitemap' => [
        'class' => 'himiklab\sitemap\Sitemap',
        'models' => [
            // your models
            'app\modules\news\models\News',
            // or configuration for creating a behavior
                [
                    '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,
                                    'xhtml:link' => [
                                        [
                                            'hreflang' => 'en',
                                            'href' => Url::to(['url_en'], true),
                                        ],
                                        [
                                            'hreflang' => 'de',
                                            'href' => Url::to(['url_de'], true),
                                        ],
                                        //...
                                    ],
                                ];
                            }
                        ],
                    ],
                ],
            ],
        ],
        'urls'=> [
            // your additional urls
            [
                'loc' => '/news/index',
                'changefreq' => 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 himiklab\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 rule for `urlManager` of your application's configuration file, for example:

```
'urlManager' => [
    'rules' => [
        ['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.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

44

—

FairBetter than 92% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 71.1% 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 ~531 days

Total

4

Last Release

2654d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfc1555d751fb9c67e860ffe7919256d967afd5438b28b5744ee5c3a798059fb?d=identicon)[himiklab](/maintainers/himiklab)

---

Top Contributors

[![himiklab](https://avatars.githubusercontent.com/u/6266409?v=4)](https://github.com/himiklab "himiklab (27 commits)")[![tsanchev](https://avatars.githubusercontent.com/u/8882098?v=4)](https://github.com/tsanchev "tsanchev (4 commits)")[![bscheshirwork](https://avatars.githubusercontent.com/u/5769211?v=4)](https://github.com/bscheshirwork "bscheshirwork (2 commits)")[![ladamalina](https://avatars.githubusercontent.com/u/2093425?v=4)](https://github.com/ladamalina "ladamalina (2 commits)")[![xr0m3oz](https://avatars.githubusercontent.com/u/4499191?v=4)](https://github.com/xr0m3oz "xr0m3oz (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/himiklab-yii2-sitemap-module/health.svg)

```
[![Health](https://phpackages.com/badges/himiklab-yii2-sitemap-module/health.svg)](https://phpackages.com/packages/himiklab-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)
