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

ActiveLibrary

aalfiann/sitemap-manager
========================

A PHP class to manage static sitemap dynamically.

1.3.1(7y ago)0251MITPHPPHP &gt;=5.4

Since Mar 15Pushed 7y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (7)Used By (0)

Sitemap Manager
===============

[](#sitemap-manager)

[![Version](https://camo.githubusercontent.com/75e26d34f8a36609254854891bc0dd4d34a864cb0a65e9d0111e7e759e31a034/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737461626c652d312e332e312d677265656e2e737667)](https://github.com/aalfiann/sitemap-manager)[![Total Downloads](https://camo.githubusercontent.com/65eeac32d3fcd21137953ea5d4855e315ca90e3d4562621404758a7bbde246c6/68747470733a2f2f706f7365722e707567782e6f72672f61616c6669616e6e2f736974656d61702d6d616e616765722f646f776e6c6f616473)](https://packagist.org/packages/aalfiann/sitemap-manager)[![License](https://camo.githubusercontent.com/aa5e4860726aa4ad98ac084810cc432ee5464cc68e681635caa1261def8c9d24/68747470733a2f2f706f7365722e707567782e6f72672f61616c6669616e6e2f736974656d61702d6d616e616765722f6c6963656e7365)](https://github.com/aalfiann/sitemap-manager/blob/HEAD/LICENSE.md)

A PHP class to manage static sitemap dynamically.

Background
==========

[](#background)

This SitemapManager class is allow you to do CRUD like insert and update url inside static sitemap. I've created this class because I need to manage sitemap for small sites which is static, file based or doesn't use any database engine.

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

[](#installation)

Install this package via [Composer](https://getcomposer.org/).

```
composer require "aalfiann/sitemap-manager:^1.0"

```

Example Usage
-------------

[](#example-usage)

### Sitemap Index

[](#sitemap-index)

#### Create blank custom sitemap index

[](#create-blank-custom-sitemap-index)

Sitemap file is required before use this class, so you have to create one if you don't have any sitemap file exists on your server.

```
require 'vendor/autoload.php';
use \SitemapManager\SitemapIndex;

$sm = new SitemapIndex;

// Create blank custom sitemap index
$sm->path = 'sitemap-index.xml';
$sm->create();
```

#### Auto insert sitemap into sitemap index

[](#auto-insert-sitemap-into-sitemap-index)

```
// Set the first sitemap file
$sm->path = 'sitemap-index.xml';
// Set the last sitemap file (will increment automatically)
$sm->setLastFile();

// Check the url in all sitemap files
$url = 'http://yourdomain.com/sitemap-test.xml';
if(!$sm->find($url)){
    $sm->addBlock($url)
        ->addLastMod(date('Y-m-d'))
        ->save();
}
```

#### Add many sitemap into sitemap index directly

[](#add-many-sitemap-into-sitemap-index-directly)

Note:

- Make sure you know the limit of the sitemap
- Enqueue will stop if you reach the limit

```
$sm->path = 'sitemap-index.xml';
for ($i=1;$iaddBlock('http://yourdomain.com/sitemap-test-'.$i.'.xml')
        ->addLastMod(date('Y-m-d'))
        ->enqueue();
}
$sm->save();
```

#### Update sitemap inside sitemap index dynamically

[](#update-sitemap-inside-sitemap-index-dynamically)

```
$url = 'http://yourdomain.com/sitemap-test-5.xml';
// Set the default path sitemap (required for finding range sitemap files)
$sm->path = 'sitemap-index.xml';
// Find the sitemap files if you not sure where is url located
$path = $sm->find($url,false);
if(!empty($path)){
    $sm->path = $path;
    $sm->setBlock($url)
        ->unsetLastMod()
        ->update();
}
```

#### Update sitemap inside sitemap index directly

[](#update-sitemap-inside-sitemap-index-directly)

Note: Make sure you have already know where is sitemap url located inside sitemap file.

```
$url = 'http://yourdomain.com/sitemap-test-4.xml';
// Set the path sitemap
$sm->path = 'sitemap-index.xml';
$sm->setBlock($url)
    ->unsetLastMod()
    ->update();
```

#### Delete sitemap inside sitemap index

[](#delete-sitemap-inside-sitemap-index)

```
$sm->path = 'sitemap-index.xml';
$sm->delete('http://yourdomain.com/sitemap-test-3.xml');
```

#### Delete many sitemap inside sitemap index

[](#delete-many-sitemap-inside-sitemap-index)

```
$sm->path = 'sitemap-index.xml';
for($i=5;$iprepareDelete('http://yourdomain.com/sitemap-test-'.$i.'.xml')->enqueue();
}
$sm->save();
```

#### Delete sitemap file

[](#delete-sitemap-file)

```
$sm->path = 'sitemap-index.xml';
$sm->deleteFile();
```

#### Generate Sitemap.xml

[](#generate-sitemapxml)

```
// Generate All sitemap index into file sitemap.xml
// Note: You need a cronjob to make this refreshed automatically
$sm->generate('https://yourdomain.com');

// Generate All sitemap include sub directories (path without trailing slash)
$sm->generate('https://yourdomain.com',['sitemap-folder-1','sitemap/folder-2']);

// Generate All sitemap index into string
echo $sm->generate('https://yourdomain.com','',false);
```

---

### Sitemap Urlset

[](#sitemap-urlset)

#### Create blank custom sitemap urlset

[](#create-blank-custom-sitemap-urlset)

Sitemap file is required before use this class, so you have to create one if you don't have any sitemap file exists on your server.

```
require 'vendor/autoload.php';
use \SitemapManager\Sitemap;

$sm = new Sitemap;

// Create blank custom sitemap urlset
$sm->path = 'sitemap-post.xml';
$sm->create();
```

#### Auto insert url into sitemap urlset

[](#auto-insert-url-into-sitemap-urlset)

```
// Set the first sitemap file
$sm->path = 'sitemap-post.xml';
// Set the last sitemap file (will increment automatically)
$sm->setLastFile();
// Check the url in all sitemap files
$url = 'http://yourdomain.com/test-suka-suka-aja-13';
if(!$sm->find($url)){
    $sm->addBlock($url)
        ->addChangeFreq('monthly')
        ->addLastMod(date('Y-m-d'))
        ->addPriority(0.9)
        ->save();
}
```

#### Add many url into sitemap urlset directly

[](#add-many-url-into-sitemap-urlset-directly)

Note:

- Make sure you know the limit of the sitemap
- Enqueue will stop if you reach the limit

```
$sm->path = 'sitemap-post.xml';
for ($i=0;$iaddBlock('http://yourdomain.com/test-suka-suka-aja-'.$i)
        ->addChangeFreq('monthly')
        ->addLastMod(date('Y-m-d'))
        ->addPriority(0.9)
        ->enqueue();
}
$sm->save();
```

#### Update Url inside sitemap urlset dynamically

[](#update-url-inside-sitemap-urlset-dynamically)

```
$url = 'http://yourdomain.com/test-suka-suka-aja-7';
// Set the default path sitemap (required for finding range sitemap files)
$sm->path = 'sitemap-post.xml';
// Find the sitemap files if you not sure where is url located
$path = $sm->find($url,false);
if(!empty($path)){
    $sm->path = $path;
    $sm->setBlock($url)
        ->setChangeFreq('daily')
        ->setLastMod(date('Y-m-d'))
        ->setPriority(0.5)
        ->update();
}
```

#### Update Url inside sitemap urlset directly

[](#update-url-inside-sitemap-urlset-directly)

Note: Make sure you have already know where is sitemap url located inside sitemap file.

```
$url = 'http://yourdomain.com/test-suka-suka-aja-7';
// Set the path sitemap
$sm->path = 'sitemap-post.xml';
$sm->setBlock($url)
    ->setChangeFreq('monthly')
    ->setLastMod(date('Y-m-d'))
    ->setPriority(0.9)
    ->update();
```

#### Delete url inside sitemap urlset

[](#delete-url-inside-sitemap-urlset)

```
$sm->path = 'sitemap-post.xml';
$sm->delete('http://yourdomain.com/test-suka-suka-aja-7');
```

#### Delete many url inside sitemap urlset

[](#delete-many-url-inside-sitemap-urlset)

```
$sm->path = 'sitemap-post.xml';
for($i=0;$iprepareDelete('http://yourdomain.com/test-suka-suka-aja-'.$i)->enqueue();
}
$sm->save();
```

How to Contribute
-----------------

[](#how-to-contribute)

### Pull Requests

[](#pull-requests)

1. Fork this `sitemap-manager` repository
2. Create a new branch for each feature or improvement
3. Send a pull request from each feature branch to the develop branch

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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

Every ~8 days

Total

6

Last Release

2571d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

dynamicsitemapSitemapdynamic

### Embed Badge

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

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

###  Alternatives

[presta/sitemap-bundle

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

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

Sitemap and sitemap index builder

5491.4M37](/packages/samdark-sitemap)[nystudio107/craft-seomatic

SEOmatic facilitates modern SEO best practices &amp; implementation for Craft CMS 5. It is a turnkey SEO system that is comprehensive, powerful, and flexible.

1741.4M46](/packages/nystudio107-craft-seomatic)[kartik-v/yii2-dynagrid

Turbo charge the Yii 2 GridView with personalized columns, page size, and themes.

743.1M27](/packages/kartik-v-yii2-dynagrid)[vipnytt/sitemapparser

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

772.2M10](/packages/vipnytt-sitemapparser)[icamys/php-sitemap-generator

Simple PHP sitemap generator.

175342.8k6](/packages/icamys-php-sitemap-generator)

PHPackages © 2026

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