PHPackages                             rohos/rssitemap - 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. rohos/rssitemap

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

rohos/rssitemap
===============

A package for generating Sitemap

1.0.0(5y ago)210MITPHPPHP &gt;=7.1.0

Since Feb 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Rohos/rssitemap)[ Packagist](https://packagist.org/packages/rohos/rssitemap)[ RSS](/packages/rohos-rssitemap/feed)WikiDiscussions master Synced 6d ago

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

RsSitemap
=========

[](#rssitemap)

A package for generating [SITEMAP](https://www.sitemaps.org/)

### 1. Installation

[](#1-installation)

```
composer require rohos/rssitemap
```

### 2. Require:

[](#2-require)

```
"require": {
    "php": ">=7.1.0"
}
```

### 3. RsSitemap Class:

[](#3-rssitemap-class)

```
use Rohos\RsSitemap\RsSitemap;

/**
* @param string $filepath - the path to the file
* @param bool $needNewLine - if true, add "new line" [default = false]
 */
$sitemap = new RsSitemap($filepath, $needNewLine);

/**
 * Return new Url()
 * @param string $pageUrl - awaits page url
 * @return \Rohos\RsSitemap\Elements\Url
 */
$url = $sitemap->newUrl();

/**
 * Writes url data to a file and previously running the buildXml () method on it
 * @param Url $url
 * @return bool
 * @throws \Rohos\RsSitemap\Exceptions\NotSetRequiredValueException
 */
$sitemap->writeUrl($url);

/**
 * Open file
 * @throws \Rohos\RsSitemap\Exceptions\FileOpenException
 */
$sitemap->openFile();

/**
 * Close file
 */
$sitemap->closeFile();

/**
 * Returns the number of urls written
 * @return int
 */
$sitemap->countUrls();

/**
 * Clear number of urls written
 * @return int
 */
$sitemap->clearCountUrls();
```

### 4. Url Class:

[](#4-url-class)

```
use Rohos\RsSitemap\Elements\Url;

/**
* @param string $newLine - "new line" [default = '']
 */
$url = new Url($newLine);

/**
 * Page URL - required
 * @param string $val - awaits page url
 * @return Url
 * @throws \Rohos\RsSitemap\Exceptions\IncorrectElementValueException
 */
$url->setLoc($val);

/**
 * Last modified date of the file - not required
 * @param string $val - Date (YYYY-MM-DD) or W3C Datetime
 * @return Url
 * @see https://www.w3.org/TR/NOTE-datetime
 */
$url->setLastmod($val);

/**
 * Likely frequency of changes to this page
 * @param string $val - one of constant \Rohos\RsSitemap\Elements\Interfaces\ChangefreqElement
 * @return Url
 * @throws \Rohos\RsSitemap\Exceptions\IncorrectElementValueException
 */
$url->setChangefreq($val);

/**
 * Priority of URLs relative to other URLs
 * @param string $val - The valid range of values is 0.0 to 1.0
 * @return Url
 * @throws \Rohos\RsSitemap\Exceptions\IncorrectElementValueException
 */
$url->setPriority($val);

/**
 * Return xml for url element and clearing data, after that you can use this object for create new xml
 * @return string
 * @throws \Rohos\RsSitemap\ExceptionsNotSetRequiredValueException
 */
$url->buildXml();
```

### 5. Example:

[](#5-example)

```
use Rohos\RsSitemap\RsSitemap;
use Rohos\RsSitemap\Elements\Interfaces\ChangefreqElement;

$filepath = 'test.xml';
$sitemap = new RsSitemap($filepath);
$pages = [
    [
        'loc' => 'https://github.com/Rohos/rssitemap',
        'lastmod' => '2021-01-25',
        'changefreq' => ChangefreqElement::ALWAYS,
        'priority' => 0.5,
    ], [
        'loc' => 'https://github.com/Rohos/rsyayml',
        'lastmod' => '2021-01-21T13:15:30Z',
        'changefreq' => ChangefreqElement::DAILY,
        'priority' => 0.7,
    ],
];

$sitemap->openFile();

$url = $sitemap->newUrl(); // or $url = new Url();

foreach ($pages as $page) {
    $sitemap->writeUrl(
        $url->setLoc($page['loc'])
            ->setLastmod($page['lastmod'])
            ->setChangefreq($page['changefreq'])
            ->setPriority($page['priority'])
    );
}

$sitemap->closeFile();

echo $sitemap->countUrls() .' URLS recorded';
$sitemap->clearCountUrls();
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1909d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05b928842aabd2481f3e9fa72761f2125a33650afdf7a33a70679031c274b21f?d=identicon)[Rohos](/maintainers/Rohos)

---

Top Contributors

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

---

Tags

xmlSitemaprssitemap

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rohos-rssitemap/health.svg)

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

###  Alternatives

[presta/sitemap-bundle

A Symfony bundle that provides tools to build your application sitemap.

3929.4M28](/packages/presta-sitemap-bundle)[rumenx/php-sitemap

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

1.3k15.1k1](/packages/rumenx-php-sitemap)[vipnytt/sitemapparser

XML Sitemap parser class compliant with the Sitemaps.org protocol.

772.2M10](/packages/vipnytt-sitemapparser)[ultrono/laravel-sitemap

Sitemap generator for Laravel 11, 12 and 13

36412.6k6](/packages/ultrono-laravel-sitemap)[demi/sitemap-generator

Yii2 component for generate sitemap.xml files.

1427.0k](/packages/demi-sitemap-generator)

PHPackages © 2026

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