PHPackages                             odanylevskyi/yii2-sitemap-xml - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. odanylevskyi/yii2-sitemap-xml

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

odanylevskyi/yii2-sitemap-xml
=============================

Sitemap extension provides functionality to generate and send xml file to the search engines.

0230↓100%PHP

Since Apr 1Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Sitemap Yii2 Extension
======================

[](#sitemap-yii2-extension)

Sitemap extension provides functionality to generate and send xml file to the search engines.

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist odanylevskyi/yii2-sitemap-xml "@dev"

```

or add

```
"odanylevskyi/yii2-sitemap-xml": "@dev"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply place the following code in your `config\main.php` in `modules` section:

```
'modules' => [
...
    'sitemap' => [
        'class' => '\odanylevskyi\sitemap\Module',
        'items' => [
            [
                'urls' => [
                    'site/index',
                    'site/login',
                    'site/contact',
                    ['hotel/view', 'id' => 1],
                    ....
                ],
            ],
        ],
...
],
```

Also you need to add this line to the `urlManager` in `components` section `'sitemap.xml' => 'sitemap/default/index'`:

```
[
    ...
    'rules' => [
        ...
        'sitemap.xml' => 'sitemap/default/index',
        ...
    ]
...
```

If you have more then one `sitemap.xml` file or you want to use `sitemap-index.xml` file you can add `useIndex` to the module settings:

```
...
    'sitemap' => [
           'class' => '\odanylevskyi\sitemap\Module',
           'useIndex' => true,
           ...
   ],
...
```

To build url using models you need to add the following to the module configuration:

```
...
    'sitemap' => [
       'class' => '\odanylevskyi\sitemap\Module',
       'items' => [
           [
               'class' => 'frontend\models\Artile',
               'urls' => [
                   ['article/view', 'id' => ':id'],
                   ['article/view-by-name', 'name' => ':title'],
                   ....
               ],
           ],
       ],
...
```

where `:id`, `:title` should be valid attributes of `Article` model. Also You can add SQL rules to your model (e.g. `Article`). For example ,lets imagine that you want to add only articles that was accepted by moderator. You can do it in the following way:

```
...
    'sitemap' => [
       'class' => '\odanylevskyi\sitemap\Module',
       'items' => [
           [
               'class' => 'frontend\models\Artile',
               'rules' => function($model) {
                   return $model->andWhere(['is_active'=>1]);
               },
               'urls' => [
                   ['article/view', 'id' => ':id'],
                   ['article/view-by-name', 'name' => ':title'],
                   ....
               ],
           ],
       ],
...
```

`rules` must be `Closure` instance another way it will be ignored.

To use file cache you need to add `expire` to the module settings where `expire` is a time in seconds. Default is -1 that means no caching.

```
...
    'sitemap' => [
       'class' => '\odanylevskyi\sitemap\Module',
       'expire' => 30*24*3600; //30 days from now
       ...
...
```

To specify priority and frequency for url use the next structure:

```
...
    'sitemap' => [
       'class' => '\odanylevskyi\sitemap\Module',
       'items' => [
           [
               'class' => 'frontend\models\Artile',
               'urls' => [
                   [
                      'path' => article/view', 'id' => ':id'],
                      'priority' => 0.5,
                      'freq' => 'monthly',
                   ],
                   [
                      'path' => 'article/view-by-name', 'name' => ':title'],
                      'priority' => 0.8,
                      'freq' => 'daily',
                   ],
                   ....
               ],
           ],
       ],
...
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ef4806d859fa13df3b57dbc9a90c68b2bfb7b60b3faadb029593364ca698a3c3?d=identicon)[Oleksii Danylevskyi](/maintainers/Oleksii%20Danylevskyi)

---

Top Contributors

[![odanylevskyi](https://avatars.githubusercontent.com/u/3847101?v=4)](https://github.com/odanylevskyi "odanylevskyi (18 commits)")[![bahirul](https://avatars.githubusercontent.com/u/8992466?v=4)](https://github.com/bahirul "bahirul (2 commits)")

### Embed Badge

![Health badge](/badges/odanylevskyi-yii2-sitemap-xml/health.svg)

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

###  Alternatives

[invaders-xx/filament-nested-list

Nested lists layout plugin for Filament

104.6k](/packages/invaders-xx-filament-nested-list)

PHPackages © 2026

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