PHPackages                             roelofjan-elsinga/sitemap-generator - 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. roelofjan-elsinga/sitemap-generator

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

roelofjan-elsinga/sitemap-generator
===================================

This package helps you to very easily generate a sitemap for your website

0.6.0(1y ago)020.9k↑24%4MITPHPPHP ^8.1|^8.2

Since Apr 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/roelofjan-elsinga/sitemap-generator)[ Packagist](https://packagist.org/packages/roelofjan-elsinga/sitemap-generator)[ GitHub Sponsors](https://github.com/roelofjan-elsinga)[ Patreon](https://www.patreon.com/roelofjanelsinga)[ RSS](/packages/roelofjan-elsinga-sitemap-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (8)Used By (4)

A Sitemap Generator with no dependencies
========================================

[](#a-sitemap-generator-with-no-dependencies)

[![CI](https://github.com/roelofjan-elsinga/sitemap-generator/actions/workflows/ci.yml/badge.svg)](https://github.com/roelofjan-elsinga/sitemap-generator/actions/workflows/ci.yml)[![StyleCI Status](https://camo.githubusercontent.com/dbeb6e86dddb20747e993a18f6c26c3d7a227bab4fbb90952072018dcbadbdf8/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137373735303732312f736869656c64)](https://github.styleci.io/repos/177750721)[![Code coverage](https://camo.githubusercontent.com/82e835d270c8583b439704daaab0bc70ac9825765fff7b2ced3c062d752b503f/68747470733a2f2f636f6465636f762e696f2f67682f726f656c6f666a616e2d656c73696e67612f736974656d61702d67656e657261746f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/roelofjan-elsinga/sitemap-generator)[![Total Downloads](https://camo.githubusercontent.com/956e53adc887fe72071db0b3048f361eea9b7afc0e13457e3468904a37c8d39c/68747470733a2f2f706f7365722e707567782e6f72672f726f656c6f666a616e2d656c73696e67612f736974656d61702d67656e657261746f722f646f776e6c6f616473)](https://packagist.org/packages/roelofjan-elsinga/sitemap-generator)[![Latest Stable Version](https://camo.githubusercontent.com/c81dff9e1143a912d2b4aa8265102ce40389abfe25bc977d361079a94f998132/68747470733a2f2f706f7365722e707567782e6f72672f726f656c6f666a616e2d656c73696e67612f736974656d61702d67656e657261746f722f762f737461626c65)](https://packagist.org/packages/roelofjan-elsinga/sitemap-generator)[![License](https://camo.githubusercontent.com/b0ac06faceca894ec2ee16ccda98fb88722f538a1b5efba115e2e1c222b3ac1f/68747470733a2f2f706f7365722e707567782e6f72672f726f656c6f666a616e2d656c73696e67612f736974656d61702d67656e657261746f722f6c6963656e7365)](https://packagist.org/packages/roelofjan-elsinga/sitemap-generator)

This package helps you to very easily generate a sitemap for your website.

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

[](#installation)

You can include this package through Composer using:

```
composer require roelofjan-elsinga/sitemap-generator
```

Usage
-----

[](#usage)

```
use SitemapGenerator\SitemapGenerator;

$generator = new SitemapGenerator();

$generator->add('https://test-url.com/');

$xml_string = (string)$generator;
// OR
$xml_string = $generator->toXML();

print $xml_string;
```

If you don't want to provide the domain name every single time, you can do any of the following steps:

```
$generator = new SitemapGenerator('https://test-url.com');

// or

$generator = new SitemapGenerator();

$generator->setDomain('https://test-url.com');

// or

$generator = SiteMapGenerator::boot('https://test-url.com');
```

Now that you have set the domain name, you can simply do this:

```
$generator->add('/');
```

This will result in:

```

        https://test-url.com/
        1
        2019-03-26
        weekly

```

Available methods:
------------------

[](#available-methods)

- `boot()`: This provides a named constructor for the SitemapGenerator class
- `remove(string $url)`: This will remove the given URL from the sitemap
- `links()`: This will given you the added URL's as an array

No duplication
--------------

[](#no-duplication)

The `add()` method will filter out any duplicate links, so adding a link twice will not result in an additional link in the sitemap.

Customization
-------------

[](#customization)

You can customize the priority, lastmod, and changefreq values by providing the `add()` method with additional information:

```
public function add(
    string $url,
    $priority = 1,
    string $last_modified = null,
    string $change_frequency = 'weekly'
): SitemapGenerator
```

This means you can do something like this:

```
$generator->add('https://test-url.com/blog', 0.9, date('Y-m-d'), 'monthly');

// Or if you've set the domain earlier, this is even simpler:

$generator = SitemapGenerator::boot()->setDomain('https://test-url.com');

$generator->add('/blog', 0.9, date('Y-m-d'), 'monthly');
```

Valid values
------------

[](#valid-values)

**priority**: A number between 0 and 1, 1 being the most important page, 0 being the least important.

**last\_modified**: any date in the "Y-m-d" format

**change\_frequency**: yearly, monthly, weekly, daily, etc.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

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

Recently: every ~483 days

Total

7

Last Release

557d ago

PHP version history (3 changes)0.1PHP &gt;=7.2.0

0.5.0PHP ^8.1

0.6.0PHP ^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/2602444740bac106e338fc57a5d16b085ba02a9ca3d714c2106dccccbf97bba2?d=identicon)[roelofjanelsinga](/maintainers/roelofjanelsinga)

---

Top Contributors

[![roelofjan-elsinga](https://avatars.githubusercontent.com/u/9220754?v=4)](https://github.com/roelofjan-elsinga "roelofjan-elsinga (22 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/roelofjan-elsinga-sitemap-generator/health.svg)

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

PHPackages © 2026

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