bitandblack/sitemap

Creates a sitemap.xml by parsing the whole website.

1.1.1 2022-05-20 12:04 UTC

This package is auto-updated.

Last update: 2023-11-10 12:51:55 UTC


README

PHP from Packagist Codacy Badge Latest Stable Version Total Downloads License

Bit&Black Sitemap

Creates a sitemap.xml by parsing the whole website including all language versions and all images.

If multiple language versions are found, multiple xml files will be written.

Installation

This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/sitemap.

Usage

Set up the sitemap generation like that:

<?php

use BitAndBlack\Sitemap\Config\YamlConfig;
use BitAndBlack\Sitemap\SitemapCrawler;
use BitAndBlack\Sitemap\Writer\FileWriter;

$config = new YamlConfig('/path/to/config.yaml');
$writer = new FileWriter('/path/to/xml/files');

$sitemapCrawler = new SitemapCrawler(
    $config,
    $writer
);

$sitemapCrawler->createSitemap('https://crawl.me');

The YamlConfig stores some information which are needed when the process needs to run in multiple steps. Therefore it needs a path where the config file may get stored.

FileWriter stores the xml files, so it needs to know a folder for those files.

createSitemap() starts the crawling. If the time limit has been reached, the process will stop and store its status in the config file. If you call createSitemap() again it will continue the process. This is helpful for large websites which may take a long time to crawl.

Options

Page limit

Set a page limit that stops the crawler when the defined page count has been reached:

<?php

$sitemapCrawler->setCrawlingLimit(500);

Help

If you have any questions, feel free to contact us under hello@bitandblack.com.

Further information about Bit&Black can be found under www.bitandblack.com.