maxzhang/sitemap
Composer 安装命令:
composer require maxzhang/sitemap
包简介
Generate a sitemap
README 文档
README
This extension simply adds a sitemap to your forum.
It uses default entries like Discussions and Users, but is also smart enough to conditionally add further entries based on the availability of extensions. This currently applies to flarum/tags and fof/pages. Other extensions can easily inject their own Resource information, check Extending below.
Modes
There are two modes to use the sitemap.
Runtime mode
After enabling the extension the sitemap will automatically be available and generated on the fly. It contains all Users, Discussions, Tags and Pages guests have access to.
Applicable to small forums, most likely on shared hosting environments, with discussions, users, tags and pages summed up being less than 10.000 items. This is not a hard limit, but performance will be degraded as the number of items increase.
Cached multi-file mode
For larger forums you can set up a cron job that generates a sitemap index and compressed sitemap files. A first sitemap will be automatically generated after the setting is changed, but subsequent updates will have to be triggered either manually or through the scheduler (see below).
A rebuild can be manually triggered at any time by using:
php flarum fof:sitemap:build
Best for larger forums, starting at 10.000 items.
Risky Performance Improvements
This setting is meant for large enterprise customers.
The optional "Enable risky performance improvements" option modifies the discussion and user SQL queries to limit the number of columns returned. By removing those columns, it significantly reduces the size of the database response but might break custom visibility scopes or slug drivers added by extensions.
This setting only brings noticeable improvements if you have millions of discussions or users. We recommend not enabling it unless the CRON job takes more than an hour to run or that the SQL connection gets saturated by the amount of data.
Scheduling
Consider setting up the Flarum scheduler, which removes the requirement to setup a cron job as advised above. Read more information about this here
The frequency setting for the scheduler can be customized via the extension settings page.
Installation
This extension requires PHP 8.0 or greater.
Install manually with composer:
composer require fof/sitemap
Updating
composer update fof/sitemap php flarum migrate php flarum cache:clear
Nginx issues
If you are using nginx and accessing /sitemap.xml results in an nginx 404 page, you can add the following rule to your configuration file, underneath your existing location rule:
location = /sitemap.xml {
try_files $uri $uri/ /index.php?$query_string;
}
This rule makes sure that Flarum will answer the request for /sitemap.xml when no file exists with that name.
Extending
Register a new Resource
In order to register your own resource, create a class that implements FoF\Sitemap\Resources\Resource. Make sure
to implement all abstract methods, check other implementations for examples. After this, register your
return [ new \FoF\Sitemap\Extend\RegisterResource(YourResource::class), ];
That's it.
Remove a Resource
In a very similar way, you can also remove resources from the sitemap:
return [ (new \FoF\Sitemap\Extend\RemoveResource(\FoF\Sitemap\Resources\Tag::class)), ];
Force cache mode
If you wish to force the use of cache mode, for example in complex hosted environments, this can be done by calling the extender:
return [ (new \FoF\Sitemap\Extend\ForceCached()), ]
Commissioned
The initial version of this extension was sponsored by profesionalreview.com.
Links
maxzhang/sitemap 适用场景与选型建议
maxzhang/sitemap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Sitemap」 「extension」 「flarum」 「flagrow」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 maxzhang/sitemap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 maxzhang/sitemap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 maxzhang/sitemap 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony sitemap generator
A custom URL rule class for Yii 2 which allows to create translated URL rules
PHP Simple Sitemap Generator
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
Interfaces for web resource models and services to retrieve and create them
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-13