PHPackages                             initbiz/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. initbiz/sitemap

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

initbiz/sitemap
===============

Basic set of objects to build a sitemap generator

1.0.5(1y ago)14.3k↓37.5%11MITPHPPHP ^8.1

Since Jul 28Pushed 1y ago2 watchersCompare

[ Source](https://github.com/initbiz/sitemap)[ Packagist](https://packagist.org/packages/initbiz/sitemap)[ Docs](https://github.com/initbiz/sitemap)[ RSS](/packages/initbiz-sitemap/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (8)Used By (1)

Sitemap
=======

[](#sitemap)

PHP library to build object oriented sitemap generator.

The package is still a work in progress so PRs are welcomed.

You have to write your own generator (I'd suggest using `AbstractGenerator` as a base) and it has to return an array containing DOMElements to include to the XML.

You can also use `BasicGenerator` but it's limited and built mostly for testing purposes.

Usage examples
--------------

[](#usage-examples)

Below you can find a few examples of usage of this library.

### Typical sitemap containing URLs

[](#typical-sitemap-containing-urls)

```
    $url1 = new UrlDOMElement();
    $url1->setLoc('https://www.example.com/foo.html');
    $url1->setLastmod('2022-06-04');
    $url1->setPriority('1.0');
    $url1->setChangefreq('always');

    $url2 = new UrlDOMElement();
    $url2->setLoc('https://www.example.com/foo2.html');
    $url2->setLastmod('2022-06-04');
    $url2->setPriority('0.9');

    $urlSetDOMElement = new UrlsetDOMElement();
    $urlSetDOMElement->setUrls([$url1, $url2]);

    $DOMElements = [$urlSetDOMElement];
    $generator = new BasicGenerator();
    $generator->setDOMElements($DOMElements);

    $xml = $generator->generate();
```

```

    https://www.example.com/foo.html
    2022-06-04T00:00:00+00:00
    always
    1.0

    https://www.example.com/foo2.html
    2022-06-04T00:00:00+00:00
    0.9

```

### Images sitemap

[](#images-sitemap)

Code below will generate the following XML:

```
    $url1 = new UrlDOMElement();
    $url1->setloc('https://example.com/sample1.html');

    $image = new ImageDOMElement();
    $image->setLoc('https://example.com/image.jpg');
    $photo = new ImageDOMElement();
    $photo->setLoc('https://example.com/photo.jpg');
    $url1->setImages([$image, $photo]);

    $url2 = new UrlDOMElement();
    $url2->setloc('https://example.com/sample2.html');
    $picture = new ImageDOMElement();
    $picture->setLoc('https://example.com/picture.jpg');
    $url2->setImages([$picture]);

    $urlSetDOMElement = new UrlsetDOMElement();
    $urlSetDOMElement->setUrls([$url1, $url2]);

    $DOMElements = [$urlSetDOMElement];
    $generator = new BasicGenerator();
    $generator->setDOMElements($DOMElements);
```

```

    https://example.com/sample1.html

      https://example.com/image.jpg

      https://example.com/photo.jpg

    https://example.com/sample2.html

      https://example.com/picture.jpg

```

### Sitemap index

[](#sitemap-index)

```
    $sitemap1 = new SitemapDOMElement();
    $sitemap1->setLoc('https://www.example.com/sitemap1.xml.gz');

    $sitemap2 = new SitemapDOMElement();
    $sitemap2->setLoc('https://www.example.com/sitemap2.xml.gz');

    $sitemapIndexDOMElement = new SitemapIndexDOMElement();
    $sitemapIndexDOMElement->setSitemaps([$sitemap1, $sitemap2]);

    $DOMElements = [$sitemapIndexDOMElement];
    $generator = new BasicGenerator();
    $generator->setDOMElements($DOMElements);

    $xml = $generator->generate();
```

```

    https://www.example.com/sitemap1.xml.gz

    https://www.example.com/sitemap2.xml.gz

```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~17 days

Total

6

Last Release

574d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16684450?v=4)[inIT](/maintainers/initbiz)[@initbiz](https://github.com/initbiz)

---

Top Contributors

[![tomaszstrojny](https://avatars.githubusercontent.com/u/8854428?v=4)](https://github.com/tomaszstrojny "tomaszstrojny (15 commits)")[![dzapek](https://avatars.githubusercontent.com/u/54842490?v=4)](https://github.com/dzapek "dzapek (5 commits)")

---

Tags

phpSitemap

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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