PHP code example of the-3labs-team / laravel-googlenews-sitemap
1. Go to this page and download the library: Download the-3labs-team/laravel-googlenews-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/ */
the-3labs-team / laravel-googlenews-sitemap example snippets
return [
'path' => 'public/google-news-sitemap.xml',
];
// Init the sitemap
$sitemap = LaravelGooglenewsSitemap::create();
// Add urls
// $articles = App\Models\Article::wherePublished()...
foreach($articles as $article) {
$sitemap->add(
url: route('articles.show', $article->slug),
authorName: $article->authorName,
title: $article->title,
lastModificationDate: $article->updated_at,
language: 'it',
);
}
// Write sitemap to disk
$sitemap->writeToDisk();
bash
php artisan vendor:publish --tag="googlenews-sitemap-config"
bash
php artisan vendor:publish --tag="laravel-googlenews-sitemap-views"