himiklab/yii2-sitemap-module
最新稳定版本:1.2.1
Composer 安装命令:
composer require himiklab/yii2-sitemap-module
包简介
Yii2 module for automatically generation XML Sitemap
README 文档
README
Yii2 module for automatically generating XML Sitemap.
Installation
The preferred way to install this extension is through composer.
- Either run
php composer.phar require --prefer-dist "himiklab/yii2-sitemap-module" "*"
or add
"himiklab/yii2-sitemap-module" : "*"
to the require section of your application's composer.json file.
- Configure the
cachecomponent of your application's configuration file, for example:
'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], ]
-
Add
use himiklab\sitemap\behaviors\SitemapBehavior;to the beginning of configuration file -
Add a new module in
modulessection of your application's configuration file, for example:
'modules' => [ 'sitemap' => [ 'class' => 'himiklab\sitemap\Sitemap', 'models' => [ // your models 'app\modules\news\models\News', // or configuration for creating a behavior [ 'class' => 'app\modules\news\models\News', 'behaviors' => [ 'sitemap' => [ 'class' => SitemapBehavior::className(), 'scope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->select(['url', 'lastmod']); $model->andWhere(['is_deleted' => 0]); }, 'dataClosure' => function ($model) { /** @var self $model */ return [ 'loc' => Url::to($model->url, true), 'lastmod' => strtotime($model->lastmod), 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8, 'xhtml:link' => [ [ 'hreflang' => 'en', 'href' => Url::to(['url_en'], true), ], [ 'hreflang' => 'de', 'href' => Url::to(['url_de'], true), ], //... ], ]; } ], ], ], ], ], 'urls'=> [ // your additional urls [ 'loc' => '/news/index', 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8, 'news' => [ 'publication' => [ 'name' => 'Example Blog', 'language' => 'en', ], 'access' => 'Subscription', 'genres' => 'Blog, UserGenerated', 'publication_date' => 'YYYY-MM-DDThh:mm:ssTZD', 'title' => 'Example Title', 'keywords' => 'example, keywords, comma-separated', 'stock_tickers' => 'NASDAQ:A, NASDAQ:B', ], 'images' => [ [ 'loc' => 'http://example.com/image.jpg', 'caption' => 'This is an example of a caption of an image', 'geo_location' => 'City, State', 'title' => 'Example image', 'license' => 'http://example.com/license', ], ], ], ], 'enableGzip' => true, // default is false 'cacheExpire' => 1, // 1 second. Default is 24 hours ], ],
- Add behavior in the AR models, for example:
use himiklab\sitemap\behaviors\SitemapBehavior; public function behaviors() { return [ 'sitemap' => [ 'class' => SitemapBehavior::className(), 'scope' => function ($model) { /** @var \yii\db\ActiveQuery $model */ $model->select(['url', 'lastmod']); $model->andWhere(['is_deleted' => 0]); }, 'dataClosure' => function ($model) { /** @var self $model */ return [ 'loc' => Url::to($model->url, true), 'lastmod' => strtotime($model->lastmod), 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'priority' => 0.8 ]; } ], ]; }
- Add a new rule for
urlManagerof your application's configuration file, for example:
'urlManager' => [ 'rules' => [ ['pattern' => 'sitemap', 'route' => 'sitemap/default/index', 'suffix' => '.xml'], ], ],
Resources
himiklab/yii2-sitemap-module 适用场景与选型建议
himiklab/yii2-sitemap-module 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 183.58k 次下载、GitHub Stars 达 91, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「xml」 「module」 「Sitemap」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 himiklab/yii2-sitemap-module 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 himiklab/yii2-sitemap-module 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 himiklab/yii2-sitemap-module 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony sitemap generator
PHP Simple Sitemap Generator
Interfaces for web resource models and services to retrieve and create them
Load DOM document safety
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
Sitemap and sitemap index builder for Jigsaw.
统计信息
- 总下载量: 183.58k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 92
- 点击次数: 19
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 未知