PHP code example of thestarraccoon / sitemap-generation-library

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

    

thestarraccoon / sitemap-generation-library example snippets


$pages = [
    [
        'loc' => 'https://example.com/home',
        'lastmod' => '2024-06-10',
        'changefreq' => 'daily',
        'priority' => '1.0'
    ],
    [
        'loc' => 'https://example.com/about-us',
        'lastmod' => '2024-06-09',
        'changefreq' => 'monthly',
        'priority' => '0.8'
    ],
    [
        'loc' => 'https://example.com/contact',
        'lastmod' => '2024-06-08',
        'changefreq' => 'yearly',
        'priority' => '0.5'
    ],
    [
        'loc' => 'https://example.com/services',
        'lastmod' => '2024-06-07',
        'changefreq' => 'weekly',
        'priority' => '0.9'
    ],
    [
        'loc' => 'https://example.com/products',
        'lastmod' => '2024-06-06',
        'changefreq' => 'daily',
        'priority' => '0.7'
    ],
    [
        'loc' => 'https://example.com/blog',
        'lastmod' => '2024-06-05',
        'changefreq' => 'weekly',
        'priority' => '0.6'
    ],
    [
        'loc' => 'https://example.com/blog/post-1',
        'lastmod' => '2024-06-04',
        'changefreq' => 'monthly',
        'priority' => '0.7'
    ],
    [
        'loc' => 'https://example.com/blog/post-2',
        'lastmod' => '2024-06-03',
        'changefreq' => 'monthly',
        'priority' => '0.6'
    ],
    [
        'loc' => 'https://example.com/blog/post-3',
        'lastmod' => '2024-06-02',
        'changefreq' => 'daily',
        'priority' => '0.8'
    ],
    [
        'loc' => 'https://example.com/privacy-policy',
        'lastmod' => '2024-06-01',
        'changefreq' => 'yearly',
        'priority' => '0.4'
    ]
];

$fileType = 'xml';
$pathToFile = '/generates/sitemap.xml';

$main = new SitemapGenerateInit($pages, $fileType, $pathToFile);
$main->initSitemapGenerate();