PHP code example of cmercado93 / laravel-simple-sitemap

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

    

cmercado93 / laravel-simple-sitemap example snippets




use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TestController;
use Cmercado93\LaravelSimpleSitemap\Common\Frequency;

Route::get('/', function () {
    return view('welcome');
})
    ->sitemap([
        'priority' => 1,
        'frequency' => Frequency::WEEKLY,
        'last_update' => '2024-01-01',
    ]);

Route::get('/test', [TestController::class, 'test'])
    ->sitemap()
    ->name('test');
xml
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>http://mi.sitio/</loc>
    <lastmod>2024-01-01T00:00:00+00:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1.0</priority>
  </url>
  <url>
    <loc>http://mi.sitio/test</loc>
  </url>
</urlset>