PHP code example of fayyaztech / sitemap-generator

1. Go to this page and download the library: Download fayyaztech/sitemap-generator 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/ */

    

fayyaztech / sitemap-generator example snippets


use Fayyaztech\SitemapGenerator\SitemapGenerator;

// Instantiate the generator with default parameters
$sitemapGenerator = new SitemapGenerator();

// Instantiate the generator with custom parameters
$sitemapGenerator = new SitemapGenerator(
    ChangeFrequency::WEEKLY,
    'https://example.com'
);

// Generate and save XML sitemap
$sitemapGenerator->saveToSitemap('/path/to/output'); // Saves an XML sitemap to the specified directory

// Generate and save ROR sitemap
$sitemapGenerator->saveToRor('/path/to/output'); // Saves a ROR sitemap (RSS format) to the specified directory

// Generate and save HTML sitemap
$sitemapGenerator->saveToHtmlSitemap('/path/to/output'); // Saves a human-readable HTML sitemap to the specified directory

// Generate and save URL list
$sitemapGenerator->saveToUrlList('/path/to/output'); // Saves a plain-text list of URLs to the specified directory