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

ActiveLibrary

lapshev/sitemap
===============

Sitemap generator library

1.0.0(8y ago)032MITPHPPHP &gt;=5.6.0

Since Sep 27Pushed 8y ago1 watchersCompare

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

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

Sitemap generator
=================

[](#sitemap-generator)

### Install

[](#install)

```
composer require lapshev/sitemap
```

### Usage

[](#usage)

1. Create generator object
2. Create provider object
3. Add provider to generator
4. Generate

Specify filename while adding provider, content of this file is the result of merge multiply providers with same filename

```
use Lapshev\Sitemap;
use Lapshev\Sitemap\Providers;

$sitemap = new Sitemap\Generator('http://example.com');
$simpleProvider = new Providers\Simple([
    ['/', new \DateTime(), 'daily', 0.5],
    ['/news/', new \DateTime(), 'monthly', 1]
]);

$sitemap->addProvider('example', $simpleProvider);
// will output to example.xml and add this file sitemap.xml

$sitemap->generate($_SERVER['DOCUMENT_ROOT']);
```

For more advantage usage your should create your own provider that implements `iProvider` interface. See example bellow:

```
namespace MySite\Sitemap\Providers;

use Lapshev\Sitemap\BaseProvider;
use Lapshev\Sitemap\Entire;
use Lapshev\Sitemap\iProvider;

class DataBase extends BaseProvider implements iProvider
{
    private $dbResult;

    private $tableName;

    public function __construct($params = []) {
        parent::__construct($params);
        $this->tableName = $params['tableName'];
    }

    // will be called before fetching
    public function prepareData() {
        $servername = "localhost";
        $username = "username";
        $password = "password";
        $dbname = "myDB";

        // Create connection
        $conn = new \mysqli($servername, $username, $password, $dbname);

        $sql = "SELECT id, pageUrl, lastMod FROM {$this->tableName}";
        $this->dbResult = $conn->query($sql);
    }

    public function getNextEntire() {
        while($row = $this->dbResult->fetch_assoc()) {
            return new Entire($row['pageUrl'], $row['lastMod'], 'daily', 0.7);
        }

        return null;
    }
}
```

### Features

[](#features)

#### Check response

[](#check-response)

```
$sitemap = new Sitemap\Generator('http://example.com', ['checkResponse' => true]);
```

Will check every url in the set and output wrong ones

### More examples

[](#more-examples)

```
use Lapshev\Sitemap\Generator;
use Lapshev\Sitemap\Providers\Simple;

use newsite\SiteMap\Providers\Elements;
use newsite\SiteMap\Providers\Files;
use newsite\SiteMap\Providers\Sections;
use newsite\SiteMap\Providers\Banners;

use Bitrix\Main\Type\DateTime;

require 'common.php';

$params = [
    'check_response'    => in_array('checkResponse', $argv)
];

$arScheme = [
    'catalog'   => [
        new Sections(['iBlockID' => CATALOG_SEO_MENU, 'indexID' => 1, 'priority' => 0.5]),
    ],
    'menu'      => [
        new Sections(['iBlockID' => CATALOG_LOGIC_MENU, 'indexID' => 1, 'priority' => 0.5]),
    ],
    'goods'     => [
        new Elements(['iBlockID' => CATALOG_PRODUCT_IBLOCK, 'indexID' => 1, 'priority' => 0.5]),
    ],
    'news'      => [
        new Simple([ ['/news/', new DateTime(), 'hourly', 1] ]),
        new Elements(['iBlockID' => 25, 'priority' => 0.8, 'changeFreq' => 'monthly']),
    ],
    'articles'  => [
        new Simple([ ['/helpful/', new DateTime(), 'hourly', 0.4] ]),
        new Elements(['iBlockID' => 29, 'priority' => 0.4]),
    ],
    'info'      => [
        new Simple([ ['/', new DateTime(), 'hourly', 1] ]),
        new Files(['priority' => 0.4])
    ],
    'sale'      => [
        new Banners(['type' => 'actionCatalogList', 'priority' => 1, 'changeFreq' => 'daily']),
    ]
];

$siteMap = new Generator('http://example.com', $params);

foreach($arScheme as $fileName => $providers) {
    foreach($providers as $provider){
        $siteMap->addProvider($fileName, $provider);
    }
}

$siteMap->generate($_SERVER['DOCUMENT_ROOT']);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3147d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ab74e3c0368d89d6b465ca35b52aea5c7f010131776b41588a9bf305ce873f6?d=identicon)[lapshev](/maintainers/lapshev)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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