singularity/yii2-sitemapgenerator

Sitemap Generator for Yii2 framework

dev-master / 1.2.x-dev 2020-11-26 15:46 UTC

This package is auto-updated.

Last update: 2024-04-26 23:24:59 UTC


README

Installation

The preferred way to install this extension is through composer.

Either run

composer require singularity/yii2-sitemapgenerator

or add

"singularity/yii2-sitemapgenerator": "~1.0"

to the require section of your composer.json file.

Usage

Quick example:

$generator = new SitemapGenerator([
    'maxURLsPerSitemap' => 20000,
    'basePath' => 'frontend/web',
    'items' => [
        'https://mysite.com',                      // url as string
        ['class' => User::class],                  // array with ['class'] that have getPublicUrl() method
        [
            'class' => Post::class,               // if ['class'] does not have getPublicUrl() method,
            'url' => function (Post $model) {     // then ['url'] must be set
                return ["/post/view/$model->id"]; // ['url'] can be value or callback
            }
        ]
    ]
]);

$count = $generator->generate();

Properties

  • baseUrl
  • basePath
  • items
  • sitemapFilename
  • sitemapIndexFilename
  • robotsFilename
  • maxURLsPerSitemap
  • fs
  • runtime

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

687474703a2f2f7777772e67726176617461722e636f6d2f6176617461722f38363633643438656136303933643263653931373231376365656361316363322e706e67
#InventTomorrow
www.singularity.is