Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sitemap

> 编程语言
Open source

Sitemap and sitemap index builder

542 stars0 likes1 views
WebsiteGitHub

About

Sitemap and sitemap index builder

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 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHPhacktoberfestphpsitemap

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

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