PHPackages                             daikazu/sitemap - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. daikazu/sitemap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

daikazu/sitemap
===============

This is my package sitemap

v3.0.0(1mo ago)0793↓50%MITPHPPHP ^8.4CI passing

Since May 2Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/daikazu/sitemap)[ Packagist](https://packagist.org/packages/daikazu/sitemap)[ Docs](https://github.com/daikazu/sitemap)[ GitHub Sponsors](https://github.com/Daikazu)[ RSS](/packages/daikazu-sitemap/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (30)Versions (9)Used By (0)

[  ![Logo for daikazu/sitemap](art/header-light.png)](https://mikewall.dev/)Laravel Sitemap Generator
=========================

[](#laravel-sitemap-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/57709d8746e8e93852dd2e1a5f7ea57455130d8e85d538b012e18009f92e37e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461696b617a752f736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/sitemap)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8bf7503d693af10c0e3f3c181d3dcc1ad2068a2a8b2e5aa90ae53e46f1a79f2d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f736974656d61702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/daikazu/sitemap/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0ae88d78e82894592f4f90d70e44d6768f09159c0e7149e5fa237cdbd7cc3003/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f736974656d61702f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/daikazu/sitemap/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ca1ca7bc328d4531b3d9a09ab6c8eafb0d703d543ba29eb7ab168e6ab71c0c06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461696b617a752f736974656d61702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/sitemap)

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.

Requirements
------------

[](#requirements)

- PHP 8.4+
- Laravel 13+

Features
--------

[](#features)

- Automatic sitemap generation with configurable cooldown periods
- **Sitemap Index Support** - Split large sitemaps into multiple files (50,000 URLs per file)
- **Model-Based Generation** - Generate sitemaps from Eloquent models (faster, includes authenticated content)
- **Hybrid Mode** - Combine crawled URLs with model-based URLs
- 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
- Storage-based sitemap management for better control

Installation
------------

[](#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 a summary of the published config file (see the full file for all options and documentation):

```
return [
    'cooldown_hours' => env('SITEMAP_COOLDOWN_HOURS', 24),

    'storage' => [
        'disk' => env('SITEMAP_STORAGE_DISK', 'public'),
        'path' => env('SITEMAP_STORAGE_PATH', 'sitemaps'),
        'filename' => env('SITEMAP_FILENAME', 'sitemap.xml'),
    ],

    'schedule' => [
        'enabled' => env('SITEMAP_SCHEDULE_ENABLED', true),
        'daily_time' => env('SITEMAP_DAILY_TIME', '00:00'),
    ],

    'skip_patterns' => [
        '/login', '/logout', '/register', '/admin', '/cart', '/checkout',
        // ... see config file for full list
    ],

    'index' => [
        'enabled' => env('SITEMAP_INDEX_ENABLED', false),
        'max_urls_per_sitemap' => env('SITEMAP_MAX_URLS', 50000),
        'filename_pattern' => env('SITEMAP_FILENAME_PATTERN', 'sitemap-%d.xml'),
        'index_filename' => env('SITEMAP_INDEX_FILENAME', 'sitemap.xml'),
    ],

    'models' => [
        // See "Model-Based Sitemap Generation" section below
    ],

    'generate_mode' => env('SITEMAP_GENERATE_MODE', 'crawl'), // 'crawl', 'models', or 'hybrid'

    'max_pagination_depth' => env('SITEMAP_MAX_PAGINATION_DEPTH', 100),
];
```

Usage
-----

[](#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 (returns null if generation fails)
$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.

### Artisan Commands

[](#artisan-commands)

```
# Generate sitemap with configured mode (crawl/models/hybrid)
php artisan app:generate-sitemap

# Generate sitemap from models only (ignores generate_mode)
php artisan app:generate-model-sitemap

# Force regenerate the sitemap (bypasses cooldown)
php artisan app:regenerate-sitemap

# Clear all generated sitemaps and reset cache
php artisan app:clear-sitemap
```

### Sitemap Index (Multi-Sitemap) Support

[](#sitemap-index-multi-sitemap-support)

For large sites with more than 50,000 URLs, enable sitemap index support:

```
// In config/sitemap.php
'index' => [
    'enabled' => true,
    'max_urls_per_sitemap' => 50000,
    'filename_pattern' => 'sitemap-%d.xml',
    'index_filename' => 'sitemap.xml',
],
```

When enabled, the package will:

- Split your sitemap into multiple files (sitemap-1.xml, sitemap-2.xml, etc.)
- Generate a sitemap index (sitemap.xml) that references all individual sitemaps
- Automatically serve the correct sitemap based on the requested URL

The main sitemap index will be available at `/sitemap.xml`, and individual sitemaps at `/sitemaps/sitemap-1.xml`, `/sitemaps/sitemap-2.xml`, etc.

### Model-Based Sitemap Generation

[](#model-based-sitemap-generation)

Generate sitemaps directly from your Eloquent models - much faster than crawling and includes dynamic/authenticated content:

```
// In config/sitemap.php
'models' => [
    \App\Models\Post::class => [
        'enabled' => true,
        'url' => fn($post) => route('posts.show', $post->slug),
        'lastmod' => 'updated_at', // column name or closure
        'changefreq' => 'weekly',
        'priority' => 0.8, // or use closure: fn($post) => $post->is_featured ? 0.9 : 0.7
        'query' => fn($query) => $query->where('published', true),
    ],
    \App\Models\Product::class => [
        'enabled' => true,
        'url' => fn($product) => route('products.show', $product),
        'lastmod' => fn($product) => $product->updated_at,
        'priority' => fn($product) => $product->in_stock ? 0.8 : 0.5,
    ],
],

// Set generation mode
'generate_mode' => 'hybrid', // Options: 'crawl', 'models', or 'hybrid'
```

**Generation Modes:**

- `crawl` - Traditional website crawling (default)
- `models` - Only generate from configured models
- `hybrid` - Combine both crawled pages and model-based URLs (with automatic deduplication)

**Hybrid Mode Deduplication:**When using hybrid mode, the package intelligently prevents duplicate URLs by:

- Tracking all model-generated URLs
- Normalizing URLs (removes trailing slashes, tracking parameters, case differences)
- Skipping crawled URLs that were already added from models
- Result: Clean sitemap with no duplicates, combining the best of both approaches!

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mike Wall](https://github.com/daikazu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~53 days

Recently: every ~40 days

Total

7

Last Release

59d ago

Major Versions

v1.0.1 → v2.0.0-beta.12025-10-06

v1.0.2 → v2.0.02025-10-21

v2.1.0 → v3.0.02026-03-18

PHP version history (2 changes)v1.0.0PHP ^8.3

v3.0.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4039367?v=4)[Mike Wall](/maintainers/daikazu)[@daikazu](https://github.com/daikazu)

---

Top Contributors

[![daikazu](https://avatars.githubusercontent.com/u/4039367?v=4)](https://github.com/daikazu "daikazu (39 commits)")

---

Tags

laravelSitemapdaikazu

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/daikazu-sitemap/health.svg)

```
[![Health](https://phpackages.com/badges/daikazu-sitemap/health.svg)](https://phpackages.com/packages/daikazu-sitemap)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
