yurcrm/sitemap-generator
Composer 安装命令:
composer require yurcrm/sitemap-generator
包简介
XML sitemaps generation
README 文档
README
XML sitemap files generator for unlimited sets of links
What is a XML sitemap?
XML sitemap is a text file with links to pages of a website. Search engines like Google or Yandex use sitemap files to discover web pages. You can help your website to be crawled more quickly by adding a sitemap file to it's root directory.
By standard each sitemap file can contain up to 50 000 links. What if you have a large website with thousands of pages? Just create few sitemaps and link them together!
This package helps you to create sitemap files for any number of pages on your website.
How it works?
My solution takes any number of links provided by you and packs them into XML files up to 50000 links and 10 MB each (sitemap_1.xml, sitemap_2.xml, etc). These limitations are configurable. It also creates an index sitemap file sitemap.xml.
After generation of sitemap files you can add index sitemap to the search engine using tools like Google Webmaster. You can also add to your robots.txt file:
Sitemap: https://yoursite.com/sitemap.xml
Requirements
PHP 7.4+ with mb_string extension
Installation
You can install this package using Composer.
composer require yurcrm/sitemap-generator
Usage example
$sitemapGenerator = new SitemapGenerator();
// your website URL
$siteUrl = 'https://example.com';
/*
* You should generate this array of links according to your website content
*/
$links = [
new SitemapUrl(
'https://www.100yuristov.com/123',
'2018-12-07',
'weekly',
0.5,
),
new SitemapUrl(
'https://www.100yuristov.com/123456',
'2018-12-07',
'weekly',
0.5,
),
];
$sitemapGenerator->setSiteUrl($siteUrl)
->setLinks($links)
->setFileSizeLimit(5*1024*1024)
->setLinksPerFileLimit(30_000)
->createSitemaps();
// save files to the folder (use absolute path)
$sitemapGenerator->saveAsFiles('/var/www/site');
Usage with generator
Use this approach for big sitemaps to limit memory usage
// $linksGenerator - PHP generator which returns SitemapUrl objects
$sitemapsCount = $sitemapGenerator->setSiteUrl('https://www.100yuristov.com')
->setFileSizeLimit(5*1024*1024)
->setLinksPerFileLimit(30_000)
->createFilesFromLinksGenerator($linksGenerator, self::TMP_SITEMAPS_FOLDER);
Any questions?
Feel free to ask me about my solution or report a bug by sending me an email: misha.sunsetboy@gmail.com
yurcrm/sitemap-generator 适用场景与选型建议
yurcrm/sitemap-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 92 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 yurcrm/sitemap-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 yurcrm/sitemap-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 92
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-07