daikazu / sitemap
This is my package sitemap
Fund package maintenance!
Daikazu
Requires
- php: ^8.3
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
- spatie/laravel-sitemap: ^7.3
Requires (Dev)
- larastan/larastan: ^2.9||^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3||^2.0
- phpstan/phpstan-deprecation-rules: ^1.1||^2.0
- phpstan/phpstan-phpunit: ^1.3||^2.0
- rector/rector: ^2.0
- tightenco/duster: ^3.2
README
A Laravel package for generating and managing XML sitemaps with caching and cooldown periods. This package provides an easy way to generate and maintain sitemaps for your Laravel applications while preventing excessive generation requests.
Features
- Automatic sitemap generation with configurable cooldown periods
- Caching of sitemap content for improved performance
- Environment-aware generation (skips generation in local environment)
- Force regeneration capability when needed
- Built on top of the popular
spatie/laravel-sitemap
package - Automatic scheduling of sitemap generation
Installation
You can install the package via composer:
composer require daikazu/sitemap
You can publish the config file with:
php artisan vendor:publish --tag="sitemap-config"
This is the contents of the published config file:
return [ // The cooldown period in hours between sitemap generations 'cooldown_hours' => env('SITEMAP_COOLDOWN_HOURS', 24), // Schedule settings for automatic sitemap generation 'schedule' => [ // Enable or disable scheduled generation 'enabled' => env('SITEMAP_SCHEDULE_ENABLED', true), // Time of day to run the daily generation (24-hour format) 'daily_time' => env('SITEMAP_DAILY_TIME', '00:00'), // Interval in minutes to check for cooldown expiration 'check_interval' => env('SITEMAP_CHECK_INTERVAL', 1), ], ];
Usage
The package provides a SitemapService
that handles sitemap generation and caching:
use Daikazu\Sitemap\Services\SitemapService; $sitemapService = app(SitemapService::class); // Generate sitemap if due (respects cooldown period) $sitemapService->generateIfDue(); // Force regenerate sitemap regardless of cooldown $sitemapService->forceRegenerate(); // Get the sitemap content $sitemapContent = $sitemapService->getSitemapContent();
The package automatically handles scheduling of sitemap generation based on your configuration settings. You can customize the scheduling behavior through the config file.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.