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

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

muhammetsafak/sitemap-generator
===============================

Basic XML Sitemap (Standard, Video, Image, News) Generator

0.2(3y ago)16MITPHPPHP &gt;=7.2

Since Jun 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/muhammetsafak/SitemapGenerator)[ Packagist](https://packagist.org/packages/muhammetsafak/sitemap-generator)[ RSS](/packages/muhammetsafak-sitemap-generator/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Sitemap Generator
=================

[](#sitemap-generator)

This class uses simple XML syntax. It is prepared simply to create a sitemap. Supports creating sitemaps for Images, Videos and News...

It has been prepared using the document provided by Google to implement current standards ().

Requirements
------------

[](#requirements)

- PHP 7.2 or higher
- PHP SimpleXML Extension
- PHP DOM Extension

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

[](#installation)

```
composer require muhammetsafak/sitemap-generator

```

Usage
-----

[](#usage)

***Note :** If you want to get the XML output as a string instead of writing it directly to a file; You can use the `getContent()` method.*

***Note :** If you want the generated XML output to be formatted, you can use the `setFormatOutput()` method.*

### Standard Sitemap Generator

[](#standard-sitemap-generator)

```
require_once "vendor/autoload.php";
use \MuhammetSafak\SitemapGenerator\Generator;

$generator = new Generator();
$generator->setBaseURL('https://example.com/');

for ($i = 1; $i addUrl($path, new DateTime(), [
        'changefreq'    => 'weekly',
        'priority'      => '0.6'
    ]);
}

$generator->save(__DIR__ . '/sitemap.xml', true);
$generator->clear();
```

The example above produces the following output;

```

        https://example.com/path/page/1
        2022-04-26T19:07:09+00:00
        weekly
        0.6

        https://example.com/path/page/2
        2022-04-26T19:07:09+00:00
        weekly
        0.6

        https://example.com/path/page/3
        2022-04-26T19:07:09+00:00
        weekly
        0.6

```

Review the following example on identifying alternatives.

```
require_once "vendor/autoload.php";
use \MuhammetSafak\SitemapGenerator\Generator;

$generator = new Generator();
$generator->setBaseURL('https://example.com/');

$generator->addAlternate('fr', 'https://example.com/fr/');
$generator->addAlternate('de', 'https://example.com/de/')

for ($i = 1; $i addUrl($path, new DateTime(), [
        'changefreq'    => 'weekly',
        'priority'      => '0.6'
    ]);
}

$generator->save(__DIR__ . '/sitemap.xml', true);
$generator->clear();
```

The example above produces the following output;

```

        https://example.com/path/page/1
        2022-04-26T19:07:09+00:00
        weekly
        0.6

        https://example.com/path/page/2
        2022-04-26T19:07:09+00:00
        weekly
        0.6

        https://example.com/path/page/3
        2022-04-26T19:07:09+00:00
        weekly
        0.6

```

### Video Sitemap Generator

[](#video-sitemap-generator)

```
require_once "vendor/autoload.php";
use \MuhammetSafak\SitemapGenerator\Generator;

$generator = new Generator(Generator::NEWS);
$generator->setBaseURL('https://example.com/');

$video = [
    'thumbnail'     => 'https://example.com/thumbs/1.jpg',
    'title'         => 'Video Title 1',
    'description'   => 'Video Description Value',
    'content_loc'   => 'https://example.com/videos/1.mp4',
    'player_loc'    => 'https://example.com/videoplayer.php?video=1',
    'duration'      => 600,
    'expiration_date'   => '2021-11-05T19:20:30+08:00', // or DateTimeInterface object
    'rating'        => '4.2',
    'view_count'    => 12345,
    'publication_date'  => '2012-11-05T19:20:30+08:00', // or DateTimeInterface object
    'family_friendly'   => true, // [true|false|"yes"|"no"]
    'platform'      => [
        'relationship'  => 'allow', // ["allow"|"deny"]
        'value'         => 'web mobil tv' // "web" "mobil" "tv"
    ],
    'restriction'   => [
        'relationship'  => 'allow', // ["allow"|"deny"]
        'value'         => 'IE GB US CA'
    ],
    'price'         => [
        'currency'  => 'EUR',
        'value'     => '1.99'
    ],
    'requires_subscription' => true, // [true|false|"yes"|"no"]
    'uploader'      => [
        'info'  => 'https://example.com/user/admin',
        'value' => 'Admin'
    ],
    'live'          => false, // [true|false|"yes"|"no"]
];

$generator->addUrl('/path/video/1', new DateTime(), $video);

$generator->save(__DIR__ . '/sitemap.xml', true);
$generator->clear();
```

The example above produces the following output;

```

     https://example.com/path/video/1

       https://example.com/thumbs/1.jpg
       Video Title 1
       Video Description Value
       https://example.com/videos/1.mp4
       https://example.com/videoplayer.php?video=1
       600
       2021-11-05T19:20:30+08:00
       4.2
       12345
       2007-11-05T19:20:30+08:00
       yes
       web mobil tv
       IE GB US CA
       1.99
       yes
       Admin

       no

```

### Image Sitemap Generator

[](#image-sitemap-generator)

```
require_once "vendor/autoload.php";
use \MuhammetSafak\SitemapGenerator\Generator;

$generator = new Generator(Generator::NEWS);
$generator->setBaseURL('https://example.com/');

$generator->addUrl('/path/page/1', new DateTime(), [
    'image' => 'https://example.com/files/image1.jpg'
]);

$generator->addUrl('/path/page/2', new DateTime(), [
    'image' => [
        'https://example.com/files/image2.jpg',
        'https://example.com/files/image3.jpg',
        'https://example.com/files/image4.jpg'
    ]
]);

$generator->save(__DIR__ . '/sitemap.xml', true);
$generator->clear();
```

The example above produces the following output;

```

        https://example.com/path/page/1

            https://example.com/files/image1.jpg

        https://example.com/path/page/2

            https://example.com/files/image2.jpg

            https://example.com/files/image3.jpg

            https://example.com/files/image4.jpg

```

### News Sitemap Generator

[](#news-sitemap-generator)

```
require_once "vendor/autoload.php";
use \MuhammetSafak\SitemapGenerator\Generator;

$generator = new Generator(Generator::NEWS);
$generator->setBaseURL('https://example.com/');

for ($i = 1; $i addUrl($path, new DateTime(), [
        'publication'   => [
            'name'      => 'The Example Times',
            'language'  => 'en'
        ],
        'title'         => 'Headline Of Breaking News #' . $i,
    ]);
}

$generator->save(__DIR__ . '/sitemap.xml', true);
$generator->clear();
```

The example above produces the following output;

```

        https://example.com/path/news/1

                The Example Times
                en

            2022-06-22
            Headline Of Breaking News #1

        https://example.com/path/news/2

                The Example Times
                en

            2022-06-22
            Headline Of Breaking News #2

        https://example.com/path/news/3

                The Example Times
                en

            2022-06-22
            Headline Of Breaking News #3

```

Credits
-------

[](#credits)

- [Muhammet ŞAFAK](https://www.muhammetsafak.com.tr) &lt;&gt;

License
-------

[](#license)

Copyright © 2022 [MIT License](./LICENSE)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

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.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

1417d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b6b34f3ac8938d8ee52ba3bd260680855dc5715c7b2929d9380de30d15a67dd?d=identicon)[muhammetsafak](/maintainers/muhammetsafak)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[dasprid/enum

PHP 7.1 enum implementation

379146.0M11](/packages/dasprid-enum)[vonage/nexmo-bridge

Provides a bridge for using the Vonage PHP SDK with the older Nexmo namespace

5310.3M3](/packages/vonage-nexmo-bridge)[mediawiki/chameleon-skin

A highly flexible MediaWiki skin using Bootstrap 4

12481.8k2](/packages/mediawiki-chameleon-skin)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[aeon-php/calendar-holidays

Holidays calendar abstraction layer for Aeon Time management framework

14212.4k3](/packages/aeon-php-calendar-holidays)

PHPackages © 2026

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