PHP code example of tasmir / sitemap

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

    

tasmir / sitemap example snippets


   Tasmir\Sitemap\Providers\SitemapServiceProvider::class,
   

'auto_collect_static_routes' => true,
'exclude_routes' => ['admin.*', 'login', 'register'],

'sitemapable_models' => [
    \App\Models\Blog::class,
],

use Tasmir\Sitemap\Traits\Sitemapable;

class Blog extends Model {
    use Sitemapable;

    public function getSitemapLoc(): string {
        return route('blog.show', $this->slug);
    }
}

use Tasmir\Sitemap\Facades\Sitemap;

Sitemap::addUrl(url('/special-page'), now()->toAtomString(), 'weekly', '0.9');

'schedule_enabled' => true,
'schedule_timezone' => 'Asia/Dhaka',
'schedule_method' => 'dailyAt',
'schedule_time' => '00:01',
bash
   php artisan vendor:publish --tag=sitemap-config
   
bash
php artisan sitemap:generate