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

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

savanasoft/seo-sitemap
======================

A powerful, flexible PHP library for generating SEO sitemaps — XML, Image, Video, News and Sitemap Index.

00PHP

Since Mar 22Pushed 3mo agoCompare

[ Source](https://github.com/dfdesign/seo-sitemap)[ Packagist](https://packagist.org/packages/savanasoft/seo-sitemap)[ RSS](/packages/savanasoft-seo-sitemap/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

🗺️ Savana Soft SEO Sitemap
==========================

[](#️-savana-soft-seo-sitemap)

A powerful, flexible PHP 8.1+ library for generating **SEO-optimized XML sitemaps** — supporting standard URLs, Images, Videos, News and Sitemap Index files, all compliant with [sitemaps.org](https://www.sitemaps.org) and [Google's sitemap extensions](https://developers.google.com/search/docs/crawling-indexing/sitemaps/overview).

---

✨ Features
----------

[](#-features)

- ✅ **Standard Sitemap** — ``, ``, ``, ``
- 🖼️ **Image Sitemap Extension** — Google image sitemap support
- 🎬 **Video Sitemap Extension** — Google video sitemap support
- 📰 **News Sitemap Extension** — Google News sitemap support
- 📂 **Sitemap Index** — Split large sites into multiple indexed sitemaps
- 🗜️ **Gzip Support** — Write compressed `.xml.gz` sitemaps
- 🛡️ **Validation** — Enforces 50,000 URL and 50MB limits automatically
- 🔒 **Immutable Value Objects** — Safe, fluent, side-effect-free API
- 🧪 **100% Tested** — PHPUnit test suite included

---

📦 Installation
--------------

[](#-installation)

```
composer require devbg/seo-sitemap
```

**Requirements:** PHP 8.1+, `ext-dom`, `ext-libxml`

---

🚀 Quick Start
-------------

[](#-quick-start)

### Simple sitemap

[](#simple-sitemap)

```
use DevBG\SeoSitemap\SitemapUrl;
use DevBG\SeoSitemap\Generators\SitemapGenerator;
use DevBG\SeoSitemap\Renderers\FileWriter;

$generator = new SitemapGenerator(prettyPrint: true);

$generator->addUrl(new SitemapUrl(
    loc: 'https://example.com/',
    lastmod: new DateTimeImmutable(),
    changefreq: SitemapUrl::CHANGE_FREQ_DAILY,
    priority: 1.0,
));

$generator->addUrl(new SitemapUrl(
    loc: 'https://example.com/about',
    changefreq: SitemapUrl::CHANGE_FREQ_MONTHLY,
    priority: 0.5,
));

// Get XML as string
echo $generator->generate();

// Or write to file
$generator->writeTo(new FileWriter(), '/var/www/public/sitemap.xml');
```

### With Image extension

[](#with-image-extension)

```
use DevBG\SeoSitemap\ImageEntry;

$url = (new SitemapUrl('https://example.com/products/laptop'))
    ->addImage(new ImageEntry(
        loc: 'https://example.com/images/laptop-front.jpg',
        caption: 'Laptop front view',
        title: 'Premium Laptop',
        license: 'https://creativecommons.org/licenses/by/4.0/',
        geoLocation: 'Sofia, Bulgaria',
    ))
    ->addImage(new ImageEntry(
        loc: 'https://example.com/images/laptop-side.jpg',
        caption: 'Laptop side view',
    ));

$generator->addUrl($url);
```

### With News extension

[](#with-news-extension)

```
use DevBG\SeoSitemap\NewsEntry;

$url = (new SitemapUrl('https://example.com/news/ai-revolution-2024'))
    ->withNews(new NewsEntry(
        publicationName: 'Example News',
        publicationLanguage: 'en',
        publicationDate: new DateTimeImmutable('2024-11-01T09:00:00Z'),
        title: 'The AI Revolution Is Here',
        keywords: 'AI, machine learning, LLM, future',
        genres: 'PressRelease, Blog',
    ));

$generator->addUrl($url);
```

### With Video extension

[](#with-video-extension)

```
use DevBG\SeoSitemap\VideoEntry;

$url = (new SitemapUrl('https://example.com/videos/php-tutorial'))
    ->addVideo(new VideoEntry(
        thumbnailLoc: 'https://example.com/thumbnails/php-tutorial.jpg',
        title: 'PHP 8.3 for Beginners',
        description: 'A complete introduction to modern PHP development.',
        contentLoc: 'https://example.com/videos/php-tutorial.mp4',
        duration: 3600,
        rating: 4.8,
        viewCount: 15000,
        publicationDate: new DateTimeImmutable('2024-01-10'),
        familyFriendly: true,
    ));

$generator->addUrl($url);
```

---

📂 Sitemap Index (Large Sites)
-----------------------------

[](#-sitemap-index-large-sites)

For sites with more than 50,000 URLs, use multiple sitemaps and an index:

```
use DevBG\SeoSitemap\Generators\SitemapIndexGenerator;
use DevBG\SeoSitemap\Renderers\FileWriter;

$index = new SitemapIndexGenerator(prettyPrint: true);

$index->addSitemap('https://example.com/sitemap-pages.xml', new DateTimeImmutable());
$index->addSitemap('https://example.com/sitemap-products.xml', new DateTimeImmutable());
$index->addSitemap('https://example.com/sitemap-blog.xml', new DateTimeImmutable());

$index->writeTo(new FileWriter(), '/var/www/public/sitemap.xml');
```

---

🧙 SitemapManager (Recommended for large projects)
-------------------------------------------------

[](#-sitemapmanager-recommended-for-large-projects)

The `SitemapManager` handles everything automatically — writes individual sitemap files and generates the index:

```
use DevBG\SeoSitemap\SitemapManager;
use DevBG\SeoSitemap\SitemapUrl;

$manager = new SitemapManager(
    baseUrl: 'https://example.com',
    outputPath: '/var/www/public',
    prettyPrint: true,
);

// Add pages to named sitemaps
$manager->sitemap('pages')
    ->addUrl(new SitemapUrl('https://example.com/', priority: 1.0))
    ->addUrl(new SitemapUrl('https://example.com/about', priority: 0.8));

$manager->sitemap('blog')
    ->addUrl(new SitemapUrl('https://example.com/blog/post-1'))
    ->addUrl(new SitemapUrl('https://example.com/blog/post-2'));

// Writes:
//   /var/www/public/sitemap-pages.xml
//   /var/www/public/sitemap-blog.xml
//   /var/www/public/sitemap.xml  ← index
$manager->write();
```

---

🗜️ Gzip Compression
-------------------

[](#️-gzip-compression)

```
use DevBG\SeoSitemap\Renderers\GzipWriter;

$generator->writeTo(new GzipWriter(), '/var/www/public/sitemap.xml.gz');
```

---

🔁 Change Frequency Constants
----------------------------

[](#-change-frequency-constants)

```
SitemapUrl::CHANGE_FREQ_ALWAYS   // always
SitemapUrl::CHANGE_FREQ_HOURLY   // hourly
SitemapUrl::CHANGE_FREQ_DAILY    // daily
SitemapUrl::CHANGE_FREQ_WEEKLY   // weekly
SitemapUrl::CHANGE_FREQ_MONTHLY  // monthly
SitemapUrl::CHANGE_FREQ_YEARLY   // yearly
SitemapUrl::CHANGE_FREQ_NEVER    // never
```

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

---

📊 Limits (enforced automatically)
---------------------------------

[](#-limits-enforced-automatically)

LimitValueURLs per sitemap50,000Max file size50 MBSolution for large sites`SitemapIndexGenerator` or `SitemapManager`---

🚀 Professional SEO &amp; Web Design Services
--------------------------------------------

[](#-professional-seo--web-design-services)

This open-source project is maintained by our team. If you need a custom solution, a high-converting website, or an expert SEO strategy, feel free to reach out to us:

- **\[Savana Soft\]** – High-end [Ecommerce Web Design](https://savana-soft.com/izgrajdane-na-onlain-magazin/) and performance-driven [SEO Services](https://savana-soft.com/seo-optimisation/).
- **Expert SEO Audit** – Get a comprehensive [analysis of your website’s visibility](https://savana-soft.com/zaiavka-konsultacia-oferta/).
- **Custom Web Development** – Scalable PHP and JavaScript solutions tailored to your business needs.

**Let's build something great together:** 👉 [**https://savana-soft.com**](https://savana-soft.com)

---

📄 License
---------

[](#-license)

MIT — see [LICENSE](LICENSE) file.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance55

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c714b39e7963717af1bc13c844c55b8ced89e68c08ea4c1d33e1d395b875004?d=identicon)[savanasoft](/maintainers/savanasoft)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[danielgsims/staticproxy

A thin proxy for static classes

118.2k](/packages/danielgsims-staticproxy)

PHPackages © 2026

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