Finds the sitemap(.xml) for a given website

1.0.2 2014-09-23 17:30 UTC



Finds the sitemap content for a given site, first by checking what is referenced in robots.txt and then checking the site root for sitemap.(xml|txt).


The "Hello World" example

$finder = new webignition\WebsiteSitemapFinder\WebsiteSitemapFinder();        
$sitemapUrl = $finder->getSitemapUrl();

$this->assertEquals($sitemapUrl, 'http://webignition.net/sitemap.xml');


Using as a library in a project

If used as a dependency by another project, update that project's composer.json and update your dependencies.

"require": {
    "webignition/website-sitemap-finder": "*"      


This project has external dependencies managed with composer. Get and install this first.

# Make a suitable project directory
mkdir ~/website-sitemap-finder && cd ~/website-sitemap-finder

# Clone repository
git clone git@github.com:webignition/website-sitemap-finder.git.

# Retrieve/update dependencies
composer.phar install


Have look at the project on travis for the latest build status, or give the tests a go yourself.

cd ~/website-sitemap-finder
phpunit tests

An instance of WebsiteSitemapFinder can be passed an HTTP client with which to retrieve the content of the specified sitemap URL.

Examine the existing unit tests to see how you can pass in a mock HTTP client to enable testing without the need to perform actual HTTP requests.