PHP code example of mikicaivosevic / laravel-sitemap

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

    

mikicaivosevic / laravel-sitemap example snippets


// config/app.php
'providers' => [
    ...
    Mikica\Sitemap\SitemapServiceProvider::class,
];

use Carbon\Carbon;

Sitemap::create()
   ->add('/page1')
   ->add('/page2')
   ->add(Url::create('/page3')->setLastModificationDate(Carbon::create('2016', '1', '1')))
   ->add(Url::create('/page4')->addXhtmlLink([
       'hreflang' => 'de',
       'rel'      => 'alternate'
       'href'     => 'http://www.example.com/deutsch/'
   ]))
   ->writeToFile($sitemapPath);