PHPackages                             merlinus1/php-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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. merlinus1/php-sitemap

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

merlinus1/php-sitemap
=====================

Framework-agnostic Sitemap generator for PHP, Laravel, and Symfony.

v1.0.0-beta1(10mo ago)020MITPHPPHP &gt;=8.2

Since Jun 17Pushed 10mo agoCompare

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

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

**[php-sitemap](https://github.com/RumenDamyanov/php-sitemap) package**
=======================================================================

[](#php-sitemap-package)

[![CI](https://github.com/RumenDamyanov/php-sitemap/actions/workflows/ci.yml/badge.svg)](https://github.com/RumenDamyanov/php-sitemap/actions)[![codecov](https://camo.githubusercontent.com/a8f9538ad1da95967469e0677aa76fa78132d463f54d24fe426f32bd13e796f1/68747470733a2f2f636f6465636f762e696f2f67682f52756d656e44616d79616e6f762f7068702d736974656d61702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/RumenDamyanov/php-sitemap)

**php-sitemap** is a modern, framework-agnostic PHP package for generating sitemaps in XML, TXT, HTML, and Google News formats. It works seamlessly with Laravel, Symfony, or any PHP project. Features include high test coverage, robust CI, extensible adapters, and support for images, videos, translations, alternates, and Google News.

---

Features
--------

[](#features)

- **Framework-agnostic**: Use in Laravel, Symfony, or any PHP project
- **Multiple formats**: XML, TXT, HTML, Google News, mobile
- **Rich content**: Supports images, videos, translations, alternates, Google News
- **Modern PHP**: Type-safe, extensible, and robust
- **High test coverage**: 100% code coverage, CI/CD ready
- **Easy integration**: Simple API, drop-in for controllers/routes
- **Extensible**: Adapters for Laravel, Symfony, and more

---

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

[](#installation)

```
composer require rumenx/php-sitemap
```

---

Usage
-----

[](#usage)

### Laravel Example

[](#laravel-example)

**Controller method:**

```
use Rumenx\Sitemap\Sitemap;

public function sitemap(Sitemap $sitemap)
{
    $sitemap->add('https://example.com/', now(), '1.0', 'daily');
    $sitemap->add('https://example.com/about', now(), '0.8', 'monthly', images: [
        ['url' => 'https://example.com/img/about.jpg', 'title' => 'About Us']
    ]);
    // Add more items as needed...
    return response($sitemap->render('xml'), 200, ['Content-Type' => 'application/xml']);
}
```

**Route registration:**

```
Route::get('/sitemap.xml', [SitemapController::class, 'sitemap']);
```

**Advanced:**

```
// Add with translations, videos, alternates, Google News
$sitemap->add(
    'https://example.com/news',
    now(),
    '0.7',
    'weekly',
    images: [['url' => 'https://example.com/img/news.jpg', 'title' => 'News Image']],
    title: 'News Article',
    translations: [['language' => 'fr', 'url' => 'https://example.com/fr/news']],
    videos: [['title' => 'News Video', 'description' => 'Video description']],
    googlenews: [
        'sitename' => 'Example News',
        'language' => 'en',
        'publication_date' => now(),
    ],
    alternates: [['media' => 'print', 'url' => 'https://example.com/news-print']]
);
```

---

### Symfony Example

[](#symfony-example)

**Controller:**

```
use Rumenx\Sitemap\Sitemap;
use Symfony\Component\HttpFoundation\Response;

class SitemapController
{
    public function sitemap(): Response
    {
        $sitemap = new Sitemap();
        $sitemap->add('https://example.com/', (new \DateTime())->format(DATE_ATOM), '1.0', 'daily');
        $sitemap->add('https://example.com/contact', (new \DateTime())->format(DATE_ATOM), '0.5', 'monthly');
        // Add more items as needed...
        return new Response($sitemap->render('xml'), 200, ['Content-Type' => 'application/xml']);
    }
}
```

**Route registration:**

```
# config/routes.yaml
sitemap:
    path: /sitemap.xml
    controller: App\Controller\SitemapController::sitemap
```

---

### Generic PHP Example

[](#generic-php-example)

```
require 'vendor/autoload.php';

use Rumenx\Sitemap\Sitemap;

$sitemap = new Sitemap();
$sitemap->add('https://example.com/', date('c'), '1.0', 'daily');
$sitemap->add('https://example.com/products', date('c'), '0.9', 'weekly', [
    ['url' => 'https://example.com/img/product.jpg', 'title' => 'Product Image']
]);
header('Content-Type: application/xml');
echo $sitemap->render('xml');
```

---

### Advanced Features

[](#advanced-features)

```
// Add with all supported fields
$sitemap->add(
    'https://example.com/news',
    date('c'),
    '0.8',
    'daily',
    images: [['url' => 'https://example.com/img/news.jpg', 'title' => 'News Image']],
    title: 'News Article',
    translations: [['language' => 'fr', 'url' => 'https://example.com/fr/news']],
    videos: [['title' => 'News Video', 'description' => 'Video description']],
    googlenews: [
        'sitename' => 'Example News',
        'language' => 'en',
        'publication_date' => date('c'),
    ],
    alternates: [['media' => 'print', 'url' => 'https://example.com/news-print']]
);

// Render as TXT
file_put_contents('sitemap.txt', $sitemap->render('txt'));

// Render as HTML
file_put_contents('sitemap.html', $sitemap->render('html'));
```

---

### add() vs addItem()

[](#add-vs-additem)

You can add sitemap entries using either the `add()` or `addItem()` methods:

**add() — Simple, type-safe, one-at-a-time:**

```
// Recommended for most use cases
$sitemap->add(
    'https://example.com/',
    date('c'),
    '1.0',
    'daily',
    images: [['url' => 'https://example.com/img.jpg', 'title' => 'Image']],
    title: 'Homepage'
);
```

**addItem() — Advanced, array-based, supports batch:**

```
// Add a single item with an array (all fields as keys)
$sitemap->addItem([
    'loc' => 'https://example.com/about',
    'lastmod' => date('c'),
    'priority' => '0.8',
    'freq' => 'monthly',
    'title' => 'About Us',
    'images' => [['url' => 'https://example.com/img/about.jpg', 'title' => 'About Us']],
]);

// Add multiple items at once (batch add)
$sitemap->addItem([
    [
        'loc' => 'https://example.com/page1',
        'title' => 'Page 1',
    ],
    [
        'loc' => 'https://example.com/page2',
        'title' => 'Page 2',
    ],
]);
```

- Use `add()` for simple, explicit, one-at-a-time additions (recommended for most users).
- Use `addItem()` for advanced, batch, or programmatic additions with arrays (e.g., when looping over database results).

---

Testing
-------

[](#testing)

```
./vendor/bin/pest
```

---

License
-------

[](#license)

[MIT License](LICENSE.md)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance53

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% 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

Unknown

Total

1

Last Release

327d ago

### Community

Maintainers

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

---

Top Contributors

[![merlinus1](https://avatars.githubusercontent.com/u/7201882?v=4)](https://github.com/merlinus1 "merlinus1 (2 commits)")[![RumenDamyanov](https://avatars.githubusercontent.com/u/1458253?v=4)](https://github.com/RumenDamyanov "RumenDamyanov (2 commits)")

---

Tags

phpsymfonylaravelxmlgeneratorhtmlSitemapgoogle-news

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[rumenx/php-sitemap

Framework-agnostic Sitemap generator for PHP, Laravel, and Symfony.

1.3k15.1k1](/packages/rumenx-php-sitemap)[ultrono/laravel-sitemap

Sitemap generator for Laravel 11, 12 and 13

36412.6k6](/packages/ultrono-laravel-sitemap)

PHPackages © 2026

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