miraclebg/php-sitemap-generator
Composer 安装命令:
composer require miraclebg/php-sitemap-generator
包简介
Simple PHP sitemap generator.
README 文档
README
Library for sitemap generation and submission.
Internally uses SplFixedArrays, thus is faster and uses less memory then alternatives.
Features:
- Follows sitemaps.org protocol
- Supports alternative links for multi-language pages (see google docs)
Usage example:
<?php include "src/SitemapGenerator.php"; // Setting the current working directory to be output directory // for generated sitemaps (and, if needed, robots.txt) // The output directory setting is optional and provided for demonstration purpose. // By default output is written to current directory. $outputDir = getcwd(); $generator = new \Icamys\SitemapGenerator\SitemapGenerator('example.com', $outputDir); // will create also compressed (gzipped) sitemap $generator->toggleGZipFileCreation(); // determine how many urls should be put into one file; // this feature is useful in case if you have too large urls // and your sitemap is out of allowed size (50Mb) // according to the standard protocol 50000 is maximum value (see http://www.sitemaps.org/protocol.html) $generator->setMaxURLsPerSitemap(50000); // sitemap file name $generator->setSitemapFileName("sitemap.xml"); // sitemap index file name $generator->setSitemapIndexFileName("sitemap-index.xml"); // alternate languages $alternates = [ ['hreflang' => 'de', 'href' => "http://www.example.com/de"], ['hreflang' => 'fr', 'href' => "http://www.example.com/fr"], ]; // adding url `loc`, `lastmodified`, `changefreq`, `priority`, `alternates` $generator->addURL('http://example.com/url/path/', new DateTime(), 'always', 0.5, $alternates); // generate internally a sitemap $generator->createSitemap(); // write early generated sitemap to file(s) $generator->writeSitemap(); // update robots.txt file in output directory or create a new one $generator->updateRobots(); // submit your sitemaps to Google, Yahoo, Bing and Ask.com $generator->submitSitemap();
Testing
Run tests with command:
$ ./vendor/bin/phpunit
Run code coverage:
$ ./vendor/bin/phpunit --coverage-html ./coverage
Changelog
New in 2.0.0:
- Major code rework
- No more public properties in generator, using only methods
- Removed
addUrlsmethod in favor ofaddUrl - Fixed bug with robots.txt update
- Fixed bug in addURL method (empty loc)
- Unit tests added for quality assurance
- Updated limits according to sitemaps spec
- Updated search engines urls
- Added change frequency validation
miraclebg/php-sitemap-generator 适用场景与选型建议
miraclebg/php-sitemap-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 123 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 01 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「php」 「Sitemap」 「PSR-2」 「PSR-1」 「PSR-4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 miraclebg/php-sitemap-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 miraclebg/php-sitemap-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 miraclebg/php-sitemap-generator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Symfony sitemap generator
PHP Simple Sitemap Generator
Interfaces for web resource models and services to retrieve and create them
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
Sitemap and sitemap index builder for Jigsaw.
统计信息
- 总下载量: 123
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-01-12