PHP code example of k-universe / tracenator

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

    

k-universe / tracenator example snippets




$siteMap = new K_Universe\Tracenator\GenerateSitemap();
foreach ($urls as $url) {
    $siteMap->addUrl([
        'location' => 'https://example.com/',
        'priority' => 0.8,
        'images' => [
            'https://example.com/image.jpg',
            'https://example.com/image-1.jpg',
        ],
        'alternates' => [
            [
                'href' => 'https://example.com/de/',
                'hreflang' => 'de',
            ],
            [
                'href' => 'https://example.com/cs/',
                'hreflang' => 'cs',
            ]
        ],
        'article' => [
            'author' => 'John Doe',
            'publication_date' => '2021-01-01',
            'title' => 'Example Article',
            'description' => 'This is an example article.',
        ],
        'videos' => [
            [
                'thumbnail_url' => 'https://example.com/video.jpg',
                'title' => 'Example Video',
                'description' => 'This is an example video.',
                // either content_url or player_url is live' => true
            ],
        ],
    ]);
}
// generates sitemap in base directory
$siteMap->export();