百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
S

sitemap

> 编程语言
开源

站点地图和站点地图索引生成器

542 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

站点地图和站点地图索引生成器

Sitemap

XML Sitemap and XML Sitemap Index builder.

Features

  • Create sitemap files: either regular or gzipped.
  • Create multi-language sitemap files.
  • Create image sitemap entries.
  • Create sitemap index files.
  • Use custom stylesheet.
  • Automatically creates new file if either URL limit or file size limit is reached.
  • Fast and memory efficient.

Installation

Installation via Composer is very simple:

bash
composer require samdark/sitemap

After that, make sure your application autoloads Composer classes by including vendor/autoload.php.

How to use it

…

Image sitemap

Pass image URLs as the fifth argument of addItem(). Each image URL is encoded and validated before it is written. A URL can have up to 1000 images.

php
$sitemap->addItem(
    'http://example.com/page-with-images',
    time(),
    Sitemap::WEEKLY,
    1,
    [
        'http://example.com/images/1.jpg',
        'http://example.com/images/2.jpg',
    ]
);

Multi-language sitemap

…

Options

There are methods to configure Sitemap instance:

  • setMaxUrls($number). Sets maximum number of URLs to write in a single file. Default is 50000 which is the limit according to specification and most of existing implementations.
  • setMaxBytes($number). Sets maximum size of a single site map file. Default is 10MiB which should be compatible with most current search engines.
  • setBufferSize($number). Sets number of URLs to be kept in memory before writing it to file. Default is 10. Bigger values give marginal benefits. On the other hand when the file size limit is hit, the complete buffer must be written to the next file.
  • setUseIndent($bool). Sets if XML should be indented. Default is true.
  • setUseGzip($bool). Sets whether the resulting sitemap files will be gzipped or not. Default is false. zlib extension must be enabled to use this feature.
  • setStylesheet($string). Sets the xml-stylesheet tag. By default, tag is not generated. See example example-sitemap-stylesheet.xsl

There is a method to configure Index instance:

  • setUseGzip($bool). Sets whether the resulting index file will be gzipped or not. Default is false. zlib extension must be enabled to use this feature.
  • setStylesheet($string). Sets the xml-stylesheet tag. By default, tag is not generated. See example example-sitemap-stylesheet.xsl

Running tests

In order to run tests perform the following command:

bash
composer test

Running PHPStan

In order to check code with PHPStan perform the following command:

bash
composer phpstan

Running Rector

In order to check code with Rector perform the following command:

bash
composer rector

In order to apply Rector changes run:

bash
composer rector:fix

Running benchmarks

The benchmark suite uses PHPBench to measure typical sitemap generation workflows from the examples above for small, medium and large websites: content sitemap generation, static sitemap generation, multi-language sitemap generation and sitemap index generation.

bash
composer bench

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPhacktoberfestphpsitemap

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言