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.2(2mo ago)056MITPHPPHP &gt;=7.4

Since Jun 25Pushed 2mo 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 today

READMEChangelog (3)Dependencies (8)Versions (4)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

36

—

LowBetter than 79% of packages

Maintenance83

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

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

Total

3

Last Release

84d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/420690?v=4)[David Villa](/maintainers/KFoobar)[@KFoobar](https://github.com/KFoobar)

---

Top Contributors

[![KFoobar](https://avatars.githubusercontent.com/u/420690?v=4)](https://github.com/KFoobar "KFoobar (3 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

3355.3M345](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.0k1](/packages/mike-bronner-laravel-model-caching)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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