singularity/yii2-sitemapgenerator

Yii2框架的网站地图生成器

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

This package is auto-updated.

Last update: 2024-09-27 00:08:46 UTC


README

安装

安装此扩展的首选方法是通过composer

运行以下命令之一

composer require singularity/yii2-sitemapgenerator

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

将以下内容添加到您的composer.json文件的require部分。

使用方法

快速示例

$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();

属性

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

贡献

有关详细信息,请参阅CONTRIBUTING

致谢

许可

BSD许可(BSD)。有关更多信息,请参阅许可文件


#InventTomorrow
www.singularity.is