站点地图和站点地图索引生成器
XML Sitemap and XML Sitemap Index builder.
Installation via Composer is very simple:
composer require samdark/sitemapAfter that, make sure your application autoloads Composer classes by including vendor/autoload.php.
…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.
$sitemap->addItem(
'http://example.com/page-with-images',
time(),
Sitemap::WEEKLY,
1,
[
'http://example.com/images/1.jpg',
'http://example.com/images/2.jpg',
]
);…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.xslThere 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.xslIn order to run tests perform the following command:
composer testIn order to check code with PHPStan perform the following command:
composer phpstanIn order to check code with Rector perform the following command:
composer rectorIn order to apply Rector changes run:
composer rector:fixThe 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.
composer bench暂无开放 Issues,或尚未同步最近议题。