定制 adamb/sitemap 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

adamb/sitemap

Composer 安装命令:

composer require adamb/sitemap

包简介

Create a sitemap for your domain, crawls all URL's except those with nofollow links and those explicitly stated to ignore to create the sitemap

README 文档

README

Generate an XML sitemap for a given URL. This class crawls any given website to create an XML sitemap for the domain.

Installation

Installation is available via Composer/Packagist, you can add the following line to your composer.json file:

"adamb/sitemap": "^1.0"

or

composer require adamb/sitemap

Usage

Example of usage can be found below:

// Method 1
$sitemap = new Sitemap\Sitemap('https://www.yourwebsite.co.uk');
$sitemap->createSitemap(); // Returns true if sitemap created else will return false

// Method 2
$sitemap = new Sitemap\Sitemap();
$sitemap->setDomain('https://www.yourwebsite.co.uk');
$sitemap->createSitemap(); // Returns true if sitemap created else will return false

Change file creation location

By default the sitemap.xml file is created in the document root but this can be altered using the following method.

$sitemap = new Sitemap\Sitemap('https://www.yourwebsite.co.uk');

// This should be an absolute path
$sitemap->setFilePath($_SERVER['DOCUMENT_ROOT'].'sitemaps/');

// or

$sitemap->setFilePath('C:\Inetpub\mywebsite.co.uk\httpdocs\sitemaps\\');

$sitemap->createSitemap();

Sitemap creation options

By default the sitemap creates a XSL stylesheet along with the sitemap. You can also change the level of the link to include in the sitemap (e.g. Only include links within 3 clicks of the homepage) and also change the filename of the sitemap on creation.

// To not include the XSL stylesheet set the first value to false when calling createSitemap();
$sitemap->createSitemap(false);

// To only include links within 3 clicks set the second value to 3
$sitemap->createSitemap(true, 3);

// To change the filename set the third value to your filename (excluding extension)
$sitemap->createSitemap(true, 5, 'mysitemapfile');

Excluding URLs

You can exclude URLs containing specific strings from the sitemap using addURLItemstoIgnore(). This is useful for excluding admin pages, login pages, or any other URLs you don't want indexed.

$sitemap = new Sitemap\Sitemap('https://www.yourwebsite.co.uk');

// Exclude a single pattern
$sitemap->addURLItemstoIgnore('admin');

// Exclude multiple patterns
$sitemap->addURLItemstoIgnore(['login', 'logout', 'private']);

$sitemap->createSitemap();

Automatic exclusions

The crawler automatically excludes pages from the sitemap based on several criteria:

  • Robots meta tags — Pages with <meta name="robots" content="noindex"> are excluded from the sitemap output. Pages with <meta name="robots" content="nofollow"> will appear in the sitemap but their links will not be followed.
  • Nofollow links — Links with rel="nofollow" on the <a> tag are not crawled.
  • Non-HTML resources — URLs ending in image extensions (jpg, jpeg, gif, png, svg, webp, bmp, ico) are skipped.
  • External links — Only links on the same domain are included.
  • Error pages — Pages returning non-200 HTTP status codes are excluded.

adamb/sitemap 适用场景与选型建议

adamb/sitemap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 194 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 adamb/sitemap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 adamb/sitemap 我们能提供哪些服务?
定制开发 / 二次开发

基于 adamb/sitemap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 194
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-11