PHP code example of bkwld / sitemap-from-routes

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

    

bkwld / sitemap-from-routes example snippets


Sitemap::add(Route::get('news', 'News@index'));
Sitemap::add('news/{article}', 'News@show'));

Sitemap::add('news', 'News@index'));
Sitemap::add('news/{article}', 'News@show')->name('article'));

namespace App;
class Article {
    public function getSitemapUrlAttribute()
    {
        return route('article', $this->slug);
    }
}