PHP code example of adamb / sitemap

1. Go to this page and download the library: Download adamb/sitemap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adamb / sitemap example snippets



// Method 1
$sitemap = new Sitemap\Sitemap('http://www.yourwebsite.co.uk');
$sitemap->createSitemap(); // Returns true if sitemap created else will return false


// Method 2
$sitemap = new Sitemap\Sitemap();
$sitemap->setDomain('http://www.yourwebsite.co.uk');
$sitemap->createSitemap(); // Returns true if sitemap created else will return false



$sitemap = new Sitemap\Sitemap('http://www.yourwebsite.co.uk');

// This should be an absolute path
$sitemap->setFilePath($_SERVER['DOCUMENT_ROOT'].'sitemaps/');

// or

$sitemap->setFilePath('C:\Inetpub\mywebsite.co.uk\httpdocs\sitemaps\\');

$sitemap->createSitemap();



// To not createSitemap(false);

// To only nge the filename set the third value to your filename (excluding extension)
$sitemap->createSitemap(true, 5, 'mysitemapfile');