PHPackages                             kfoobar/laravel-smart-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. kfoobar/laravel-smart-sitemap

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

kfoobar/laravel-smart-sitemap
=============================

A Laravel package for generating dynamic sitemaps

v1.0.1(7mo ago)038MITPHPPHP &gt;=7.4

Since Jun 25Pushed 7mo agoCompare

[ Source](https://github.com/KFoobar/laravel-smart-sitemap)[ Packagist](https://packagist.org/packages/kfoobar/laravel-smart-sitemap)[ RSS](/packages/kfoobar-laravel-smart-sitemap/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

Dynamic Sitemap Generator for Laravel
=====================================

[](#dynamic-sitemap-generator-for-laravel)

A lightweight Laravel package for generating sitemaps dynamically and on demand.

Designed with simplicity in mind, this package makes it easy to build and serve up-to-date sitemaps directly from your routes or controllers—without relying on caching, scheduled tasks, or pre-generated files.

Ideal for applications with frequently changing content, multi-language setups, or dynamic routing.

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

[](#installation)

Install the package via Composer:

```
composer require kfoobar/laravel-smart-sitemap
```

Usage
-----

[](#usage)

This package provides three functions: **add()**, **generate()** and **view()**.

- **add(url, modified)** – Adds a URL to the sitemap. The second parameter is optional and represents the last modified date.
- **generate()** – Returns the sitemap as a string.
- **view()** – Returns the sitemap as a proper XML response.

Note: The `priority` and `changefreq` fields are intentionally excluded, as Google no longer considers them relevant.

### Using the Facade

[](#using-the-facade)

Add URLs and generate the sitemap using the provided facade:

```
use KFoobar\SmartSitemap\Facades\Sitemap;

Sitemap::add('https://example.com', now());
Sitemap::generate();
```

### Using the Factory

[](#using-the-factory)

Alternatively, instantiate the factory directly for more granular control:

```
use KFoobar\SmartSitemap\SitemapFactory;

(new SitemapFactory)
    ->add('https://example.com')
    ->add('https://example.com/about')
    ->generate();
```

### Example: Serving a Dynamic Sitemap

[](#example-serving-a-dynamic-sitemap)

Here’s a simple way to implement a dynamic sitemap in your Laravel application. Just define a route and return the sitemap directly from a controller—no need for pre-generating files or scheduled jobs.

Define a route in `routes/web.php`:

```
Route::get('sitemap.xml', [SitemapController::class, 'index'])->name('sitemap');
```

Create the controller `app/Http/Controllers/SitemapController.php`:

```
namespace App\Http\Controllers;

use App\Models\Content\Post;
use KFoobar\SmartSitemap\Factories\SitemapFactory;

class SitemapController extends Controller
{
    public function index()
    {
        $sitemap = new SitemapFactory;

        foreach (['home', 'about'] as $route) {
            $sitemap->add(route($route));
        }

        foreach (Post::all() as $post) {
            $sitemap->add(
                route('posts.show', $post),
                $post->updated_at->toIso8601String()
            );
        }

        return $sitemap->view();
    }
}
```

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

[](#contributing)

Contributions are welcome!

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance62

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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 ~85 days

Total

2

Last Release

235d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae505c80b111fa602b53cd7ddc18f1d5e8a5427d30e3b74468ab5a48a59c0487?d=identicon)[KFoobar](/maintainers/KFoobar)

---

Top Contributors

[![KFoobar](https://avatars.githubusercontent.com/u/420690?v=4)](https://github.com/KFoobar "KFoobar (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kfoobar-laravel-smart-sitemap/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[prologue/alerts

Prologue Alerts is a package that handles global site messages.

3486.1M30](/packages/prologue-alerts)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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