PHP code example of crodas / sitemap-generator

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

    

crodas / sitemap-generator example snippets




use crodas\SitemapGenerator\SitemapGenerator;

$generator = new SitemapGenerator("https://corruptos.net/sitemap", __DIR__ . "/public_html/sitemap/");
$generator->limit(1000);

$generator = $generator->addMap(['foo', 'bar', 'xxx', 'yyy'], function($obj) {
    return new Multiple([
        '/1/' . $obj,
        '/2/' . $obj,
        '/3/' . $obj,
    ]);
}, 'foobar.xml');

$generator = $generator->addMap($databaseResult, function($obj) {
    return $obj->url;
}, 'foobar.xml');