PHPackages                             migvitram/yii2-xml-generator - 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. migvitram/yii2-xml-generator

ActiveYii2-extension

migvitram/yii2-xml-generator
============================

Module for generation xml files on-the-fly (e.g. sitemap.xml)

v1.0.0(6y ago)026MITPHP

Since Apr 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/migvitram/yii2-xml-generator)[ Packagist](https://packagist.org/packages/migvitram/yii2-xml-generator)[ RSS](/packages/migvitram-yii2-xml-generator/feed)WikiDiscussions master Synced yesterday

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

Simple xml module for Yii2
==========================

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

Module for xml files generation on-the-fly (e.g. sitemap.xml)

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist migvitram/yii2-xml-generator "*"

```

or add

```
"migvitram/yii2-xml-generator": "*"

```

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

Usage
-----

[](#usage)

After installation, modify the web.php config file, modules section:

```
 'modules' => [
    ...
    'xmlGenerator' => [
        'class' => 'migvitram\xmlgenerator\XmlGeneratorModule',
        'pages' => ['\app\models\Page', 'getPagesForSitemap'],
        'atom' => ['\app\models\Page', 'getItemsForAtom'],
        'rss' => ['\app\models\Page', 'getItemsForRss'],
    ]
 ]
```

, where can be passed callback function to retrieve the array of items for sitemap.xml, atom.xml and rss.xml files.

Callback methods must generate array of arrays, where every child need to satisfy that format :

```
 [
    ...
    [
        'loc' => Url::base(true) . 'your/pages/url',
        'lastmod' => '2016-10-10', // date of page modification in format 'Y-m-d'
        'changefreq' => migvitram\xmlgenerator\models\SitemapSchema::CHANG_FREQ_MONTH, // frequency of changing
        'priority' => 0.8,  // priority in double type number
    ],
    ...
 ]
```

, according to [sitemap protocol](https://www.sitemaps.org/protocol.html).

For example, method `getPagesForSitemap` in Page model can be looks like:

```
 namespace your\app\namespace;

 use yii\base\Model;
 use yii\helpers\Url;
 use migvitram\xmlgenerator\models\schemas\Sitemap\SitemapSchema;

 class Page extends Model
 {
     /**
      * @return array
      */
     public static function getPagesForSitemap()
     {
         return [
             [
                 'loc' => Url::base(true),
                 'lastmod' => '2016-10-10',
                 'changefreq' => SitemapSchema::CHANG_FREQ_DAY,
                 'priority' => 0.8,
             ],
             [
                 'loc' => Url::base(true).'/site/about',
                 'lastmod' => '2016-10-10',
                 'changefreq' => SitemapSchema::CHANG_FREQ_YEAR,
                 'priority' => 0.8,
             ],
             [
                 'loc' => Url::base(true).'/site/contact',
                 'lastmod' => '2016-10-10',
                 'changefreq' => SitemapSchema::CHANG_FREQ_MONTH,
                 'priority' => 0.8,
             ],
             [
                 'loc' => Url::base(true).'/site/news',
                 'lastmod' => '2016-10-10',
                 'changefreq' => 'monthly',
                 'priority' => 0.8,
             ],
         ];
     }
 }
```

Method to get data for rss.xml must return array with next required fields :

```
use migvitram\xmlgenerator\models\schemas\Rss\RssSchema;

class Page extends Model
 {
     /**
      * @return array
      */
     public static function getItemsForRss()
     {
         // gather all needed news

         return [
             RssSchema::TITLE_FIELD    => 'some title',  // RssSchema constant for field name can be used
             RssSchema::LINK_FIELD    => 'soem link /',
             RssSchema::DESCRIPTION_FIELD    => 'description here',
             'image' => [
                 'title' => 'aodfijoisdjf IMAGE',
                 'link' => Url::base(true).'/aodfijoisdjf987',
                 'url' => 'aodifj/asodifj.sod'
             ],
             'language' => 'ru',
             'items' => [
                 [
                     RssSchema::TITLE_FIELD => '1 title of entry',
                     RssSchema::LINK_FIELD => 'http://example.org/2003/12/13/atom03',
                     RssSchema::DESCRIPTION_FIELD => 'asdf joiasdjf oiajsdfa9s8dhf ajksdnf admfa suidhf9 ashd9f8h',
                     'someOption' => 'asdfoij'
                 ],
                 [
                     RssSchema::TITLE_FIELD  => '2 title of entry',
                     RssSchema::LINK_FIELD  => 'http://example.org/2003/12/13/atom03',
                     RssSchema::DESCRIPTION_FIELD  => 'asdf joiasdjf oiajsdfa9s8dhf ajksdnf admfa suidhf9 ashd9f8h',
                     'author' => 'ADFd Adfid',
                 ],
                 [
                     RssSchema::TITLE_FIELD  => '3 title of entry',
                     RssSchema::LINK_FIELD  => 'http://example.org/2003/12/13/atom03',
                     RssSchema::DESCRIPTION_FIELD  => 'asdf joiasdjf oiajsdfa9s8dhf ajksdnf admfa suidhf9 ashd9f8h',
                     'comments' => 'aodsfijoasidfjoij/aoidjsfoijadf/aoidsjf',
                 ],
             ],
         ];
     }
 }
```

items and channel sections can have optional fields, according to rss [documentation](https://validator.w3.org/feed/docs/rss2.html)

Method to get data for atom.xml must return array with Atom feed required fields and required `items` array :

```
use migvitram\xmlgenerator\models\schemas\Atom\AtomSchema;

 class Page extends Model
 {
     /**
      * @return array
      */
     public static function getItemsForAtom()
     {
         // gather all needed news

         return [
             'title'     => 'Feed title',
             'link'      => 'your/site/url',
             'updated'   => '2020-04-10T11:50Z',
             'author'    => 'John Doe',
             'id'    => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
             'items' => [
                 [
                     AtomSchema::ENTRY_TITLE_FIELD  => '1 title of entry',  // AtomSchema constant for field name can be used
                     AtomSchema::ENTRY_LINK_FIELD  => 'http://example.org/2003/12/13/atom01',
                     AtomSchema::ENTRY_UPDATE_FIELD  => '2016-10-10T6:50Z',
                     AtomSchema::ENTRY_SUMMARY_FIELD  => 'Some summary about article',
                     AtomSchema::ENTRY_ID_FIELD        => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
                 ],
                 [
                     'title' => '2 title of entry',
                     'link' => 'http://example.org/2003/12/13/atom02',
                     'updated' => '2016-10-10T6:50Z',
                     'summary' => 'Some summary about article',
                     'id'    => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
                 ],
                 [
                     'title' => '3 title of entry',
                     'link' => 'http://example.org/2003/12/13/atom03',
                     'updated' => '2016-10-10T6:50Z',
                     'summary' => 'Some summary about article',
                     'id'    => 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6 or some your own',
                 ],
             ],
         ];
     }
 }
```

, according to atom.xml [documentation](https://validator.w3.org/feed/docs/atom.html#sampleFeed).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

4

Last Release

2208d ago

Major Versions

v0.1.3 → v1.0.02020-04-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/562d20910dd31f212a7924af4d501f4e8db31b8d45c6c21809407bb99d64c890?d=identicon)[migvitram](/maintainers/migvitram)

---

Top Contributors

[![migvitram](https://avatars.githubusercontent.com/u/15262155?v=4)](https://github.com/migvitram "migvitram (33 commits)")

---

Tags

yii2extensionSitemap

### Embed Badge

![Health badge](/badges/migvitram-yii2-xml-generator/health.svg)

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

###  Alternatives

[dmstr/yii2-pages-module

Application sitemap and navigation manager module for Yii 2.0 Framework

3177.5k2](/packages/dmstr-yii2-pages-module)[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[mrssoft/yii2-sitemap

Yii2 sitemap extension

1123.9k1](/packages/mrssoft-yii2-sitemap)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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