gimucco/sitemap 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

gimucco/sitemap

Composer 安装命令:

composer require gimucco/sitemap

包简介

Generate Sitemaps and Sitemap Index for SEO

README 文档

README

Dynamic Sitemap generator in PHP with multi-sitemap and sitemap index support. Optional support for multi-language via hreflang

Features

Current features include:

  • Generate Single Sitemap
  • Generate Multiple Sitemaps if submitting more than 500,000 URLs
  • Automatically generate Sitemap Index
  • Specify if URL is mobile-ready
  • Multi-language support with hreflang
  • Customise names and paths to save the XML
  • Ping Google

Working on

  • Image support
  • Video Support

Requirements

PHP >= 7.4

Installation

Install via Composer

composer require gimucco/sitemap

Code Example for generating a simple sitemap

The below code shows how to generate a simple sitemap starting from an array of URLs. Refer to the examples folder for more detailed examples and options.

use Gimucco\Sitemap\Runner;
use Gimucco\Sitemap\Url;

require_once __DIR__.'/../vendor/autoload.php';

// This is the Path where the xml files will be saved.
$sitemaps_folder_path = __DIR__.'/sitemaps/';
// This is the URL corresponding to the path above
$sitemaps_folder_url = 'https://yourdomain.com/sitemaps/';
// Array containing your URLs
$urls = ['https://yourdomain.com/', 'https://yourdomain.com/contacts', 'https://yourdomain.com/signup', 'https://yourdomain.com/login'];

// Starting the Runner
// First parameter is the local path to the folder where Sitemaps will be saved
// Second parameter is the URL to reach the sitemaps
// Third parameter are options, E.g. Verbosity
$_Runner = new Runner($sitemaps_folder_path, $sitemaps_folder_url, [Runner::OPTION_VERBOSE]);
foreach ($urls as $url) {
	// Push the URL to the sitemap
	// First parameter is the URL of the resource you want to add to the sitemap
	// Second parameter is the Date of last update in ISO8601 format
	// Third parameter is  the priority (0.1 to 1)
	// Fourth parameter is the update frequency (e.g. daily)
	$_Runner->pushURL($url, Url::timeNow(), Url::PRIORITY_HIGHEST, Url::FREQ_ALWAYS);
}
// Write Sitemaps and cleanup
$_Runner->end();
// Optional, send Ping to Google to refresh the Sitemap
$_Runner->pingGoogle();

Utilities: Frequency

The Url class contains default priority values in public constants.

Sitemap::FREQ_ALWAYS; // always
Sitemap::FREQ_HOURLY; // hourly
Sitemap::FREQ_DAILY; // daily
Sitemap::FREQ_WEEKLY; // weekly
Sitemap::FREQ_MONTHLY; // monthly
Sitemap::FREQ_YEARLY; // yearly
Sitemap::FREQ_NEVER ; // never

Utilities: Priority

The Url class contains default priority values in public constants.

Sitemap::PRIORITY_HIGHEST; //1;
Sitemap::PRIORITY_HIGHER; //0.9;
Sitemap::PRIORITY_HIGH; //0.7;
Sitemap::PRIORITY_AVERAGE; //0.5;
Sitemap::PRIORITY_LOW; //0.3;
Sitemap::PRIORITY_LOWER; //0.2;
Sitemap::PRIORITY_LOWEST; //0.1;

Utilities: Last Update

The Url class contains public static methods to convert dates and timestamps to the correct format for Sitemaps: ISO8601

Url::convertDateToISO8601("2022-03-13 12:34:56");
// Output: 2022-03-13T12:34:56+00:00

Url::convertTimestampToISO8601(1647147559);
// Output: 2022-03-13T04:59:19+00:00

Furthermore, the Url class contains standard times (already formatted in ISO8601) as public static methods.

Sitemap::timeNow(); // Now
Sitemap::timeYesterday(); // 24 hours ago
Sitemap::timeOneWeek(); // One week ago {
Sitemap::timeOneMonth(); // One month ago

Examples

Refer to the examples folder for quick examples on how to use the various options

Available Examples:

  • Small, simple sitemap
  • Large, random sitemap
  • Complex sitemap with multiple languages per URL
  • Rename sitemap

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2022-03-13