mima/yii2-sitemap-generator
Composer 安装命令:
composer require mima/yii2-sitemap-generator
包简介
Library for create and write sitemap.xml for you site. Yii2 implementation.
README 文档
README
This library is implementation of mima/sitemap-generator for yii2 framework. It delivers a custom component and writer based on yii2 features. Documentation about sitemap generator library you can find here.
Installation
Install with composer from command line:
composer require mima/yii2-sitemap-generator
Or add dependency to require section in your composer.json:
{
"require": {
"mima/yii2-sitemap-generator": "~1.0"
}
}
Usage
Configure component on runtime:
use SitemapGenerator\Component\SitemapGeneratorComponent; use SitemapGenerator\Factory\SimpleGeneratorFactory; use MyNamespace\Extractor\MyDataExtractor; \Yii::$app->set('sitemapGenerator', [ 'class' => SitemapGeneratorComponent::class, 'directoryToSaveSitemap' => '@webroot', 'fileName' => 'sitemap.xml', 'extractor' => MyDataExtractor::class, 'generatorFactory' => SimpleGeneratorFactory::class ]);
Configure in application config:
return [ // ... 'components' => [ 'sitemapGenerator' => [ 'class' => SitemapGenerator\Component\SitemapGeneratorComponent::class, 'directoryToSaveSitemap' => '@webroot', 'fileName' => 'sitemap.xml', 'extractor' => MyNamespace\Extractor\MyDataExtractor::class, 'generatorFactory' => SitemapGenerator\Factory\SimpleGeneratorFactory::class ] ] //... ];
The following are valid settings:
- directoryToSaveSitemap - real path or yii alias to directory, where sitemap will be saved
- fileName - name of sitemap file
- extractor - name of class instance of
SitemapGenerator\Extractor\DataExtractorInterface - generatorFactory - name of class instance of
SitemapGenerator\Factory\GeneratorFactoryInterface
For generating sitemap call generate method:
// This code generate sitemap and return path to file, containig sitemap $filePath = \Yii::$app->get('sitemapGenerator')->generate();
统计信息
- 总下载量: 63
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-27