Library / SDK
RumenDamyanov/php-sitemap avatar
RumenDamyanov/php-sitemap

RumenDamyanov/php-sitemap: PHP Sitemap Generation for Multiple Formats

Framework-agnostic PHP package for generating sitemaps in XML, TXT, HTML, and Google News formats.

1,340 stars274 forksPHPMIT

At a glance

What is it?
RumenDamyanov/php-sitemap is a framework-agnostic PHP 8.2 package for generating XML, TXT, HTML, and Google News sitemaps. It fits Laravel, Symfony, and generic PHP applications that need typed sitemap entries, rich metadata, and several rendering formats.
Who is it for?
Adopt php-sitemap when a PHP application needs to build typed sitemap entries and render several formats without tying its domain logic to a framework. Do not choose it when the application needs automatic URL discovery, crawl scheduling, search engine submission, or a runtime outside PHP.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 50 days ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 23, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What problem php-sitemap addresses

RumenDamyanov/php-sitemap solves the problem of constructing sitemap documents inside a PHP application while keeping the application’s route or controller logic independent of the XML output format. The package is aimed at PHP developers working with Laravel, Symfony, or a generic Composer-managed project. It is not a crawler, and the README does not describe automatic URL discovery, crawl scheduling, search engine submission, or indexing guarantees. Its role begins after the application has identified URLs and their metadata.

The package covers a broad set of sitemap inputs. The documented `add()` calls accept a URL, modification date, priority, change frequency, and optional fields for images, videos, translations, alternates, titles, and Google News data. The output side includes XML, TXT, HTML, Google News, and mobile formats. That combination is useful when the same URL catalog must be exposed through different representations or when multilingual and media-rich pages require more than a simple URL list.

The intended users are application developers who already know which pages belong in the sitemap and need a typed PHP object to collect them. It can also fit content-heavy sites, such as news, blogs, catalogs, and multilingual applications, because the README explicitly lists Google News, translations, alternates, images, and videos among its supported features. The repository also contains examples for blogs, e-commerce, large-scale sitemaps, memory optimization, and sitemap indexes, although the README excerpt does not document every option in those files.

The Sitemap object and rendering pipeline

The visible API centers on `Rumenx\Sitemap\Sitemap`. Applications create the object, call `add()` for each page, and then choose a renderer such as `renderXml()`. In the generic PHP example, the object is populated with `date('c')` values and rendered after an XML content header is sent. This separation makes the data model the central component, with rendering selected at the endpoint or command that exposes the sitemap.

Laravel usage follows a different rendering path. The controller receives `Sitemap` through dependency injection, adds entries, reads the model with `$sitemap->getModel()->getItems()`, and passes those items to a view called `sitemap.xml`. The route example exposes that controller at `/sitemap.xml`. The README therefore presents Laravel rendering as a view-level integration rather than requiring the controller to call `renderXml()`.

The `add()` signature exposes a compact entry model. Required-looking positional values in the examples are the URL, date, priority, and frequency. Named arguments then add optional structured fields, such as `images`, `title`, `translations`, `videos`, `googlenews`, and `alternates`. The package also documents built-in validation for URLs, priority, and frequency, plus a fluent configuration class named `SitemapConfig`.

The repository includes adapters for Laravel and Symfony, and its directory layout contains `src/`, `tests/`, `examples/`, `composer.json`, and framework configuration files. The README does not describe the internal classes behind the adapters, so the exact extension points should be checked in `src/` before relying on a custom adapter.

Installing php-sitemap and creating the first XML sitemap

The README requires PHP 8.2 or later and Composer. Install the package through Composer with the documented package name. The README says that no additional configuration is required for basic use.

bash
composer require rumenx/php-sitemap

For a generic PHP application, load Composer’s autoloader, create `Sitemap`, add at least one URL, set the response content type, and render XML. This first use keeps the example close to the package’s public API and does not require Laravel or Symfony.

php
require 'vendor/autoload.php';

use Rumenx\Sitemap\Sitemap;

$sitemap = new Sitemap();
$sitemap->add('https://example.com/', date('c'), '1.0', 'daily');

header('Content-Type: application/xml');
echo $sitemap->renderXml();

The expected result is an XML sitemap response containing the entry supplied to `add()`. In a web application, the output should be returned from a route or controller rather than executed as an unrestricted script. The Symfony example makes that boundary explicit: it returns a `Symfony\Component\HttpFoundation\Response` with `Content-Type` set to `application/xml`.

The README gives no command for starting a demo server, no sample output file, and no browser-check procedure. Those details would need to come from the application integration rather than from the README.

Laravel and Symfony integration paths

Laravel users can inject `Sitemap` into a controller method. The documented method adds two pages, including an image entry for an about page, then retrieves the items from the model and passes them to a `sitemap.xml` view. This approach gives the application control over the view template and HTTP response. The README does not include the contents of `sitemap.xml`, so its exact XML element structure cannot be confirmed from the README.

php
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']
    ]);

    $items = $sitemap->getModel()->getItems();
    return response()->view('sitemap.xml', compact('items'), 200, ['Content-Type' => 'application/xml']);
}

Registering the controller uses the framework’s normal route syntax. The route name and controller class in the example are application-specific, so the class must be adapted to the project’s namespace.

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

Symfony uses direct rendering. The controller creates `Sitemap` itself, adds entries with formatted dates, calls `renderXml()`, and wraps the result in a `Response`. The route YAML binds `/sitemap.xml` to the controller method.

php
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');

        $xml = $sitemap->renderXml();
        return new Response($xml, 200, ['Content-Type' => 'application/xml']);
    }
}
yaml
sitemap:
    path: /sitemap.xml
    controller: App\Controller\SitemapController::sitemap

Rich entries, multiple formats, and framework neutrality

The package’s distinguishing choice is to treat sitemap data as structured PHP input instead of limiting the model to URL strings. An advanced `add()` call can attach images, a title, translations, videos, Google News publication data, and alternate media links. The README’s example uses named arguments, which makes the metadata visible at the call site and keeps the base URL and freshness fields together.

php
$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' => now(),
    ],
    alternates: [['media' => 'print', 'url' => 'https://example.com/news-print']]
);

This is not limited to XML. The feature list names XML, TXT, HTML, Google News, and mobile formats. That matters for applications that need a plain-text URL list, a browsable HTML representation, or a news-specific document. The README does not show the method names for every non-XML renderer, so the supported output should be confirmed against the relevant renderer class before designing an endpoint around it.

Framework neutrality means the package can run in Laravel, Symfony, or another PHP application, not that the application has no integration work. The Laravel example still needs a route, controller, and view. Symfony still needs a controller and route configuration. The package removes a framework-specific sitemap API, but it does not remove the host application’s routing, caching, or deployment responsibilities.

Validation, configuration, and scale-related boundaries

The README identifies built-in validation for URLs, priorities, and frequencies, and names `SitemapConfig` as the fluent configuration class. Those features can catch incorrect entry values before rendering, but the README does not state whether validation failures throw exceptions, return errors, or use another failure mechanism. That distinction matters to an application that needs to report bad database records while generating a sitemap.

The repository includes examples named `large-scale-sitemaps.md`, `memory-optimization.md`, `caching-strategies.md`, `dynamic-sitemaps.md`, and `sitemap-index.md`. Their presence shows that large or generated sitemap workflows are part of the project’s example set. The README does not include their contents, so it does not confirm whether the package supports streaming, chunking, a database iterator, automatic sitemap indexes, or a particular cache backend. Those are separate capabilities from the in-memory `Sitemap` and `getItems()` pattern shown in the Laravel example.

The package also does not present itself as a complete SEO system. The README links to a separate `php-seo` project for broader search-related functionality. That separation suggests sitemap generation is one focused concern. It also means teams should not infer from this package that metadata management, robots directives, canonical tags, or search engine submission are included.

The repository’s quality tooling is visible through `phpstan.neon`, `phpcs.xml`, `phpunit.xml`, and GitHub workflow badges in the README. The README also claims 100% code coverage, PHPStan Level max, and PSR-12 support. Those are project claims and configuration signals, not a performance measurement or a guarantee that every integration path is suitable for production.

Maintenance, licensing, and upgrade considerations

The repository is not archived. Its last push was on 2026-09-03, and the listed releases include `v1.0.4` on 2026-09-03, `v1.0.3` on 2026-08-24, and `v1.0.2` on 2025-12-13. That release history gives the package a visible maintenance record, but it does not establish compatibility with every future PHP release or framework version. An adopter still needs to check the package’s `composer.json` constraints against the application’s PHP and dependency versions.

The package is licensed under MIT. That permits use and modification under the license’s conditions, while obligations such as retaining the copyright and license notice should be handled according to the license text. This article does not provide legal advice. Teams that distribute a generated sitemap should separately consider their application and hosting obligations.

Upgrading means reviewing `CHANGELOG.md`, `composer.json`, and the relevant example files rather than assuming that every `add()` signature remains unchanged. The README does not document a rollback procedure or a compatibility matrix for Laravel and Symfony. It also does not state how generated sitemaps should be cached or invalidated. Those are deployment questions, and the repository’s examples should be consulted before changing a production sitemap route.

Editorial conclusion

Adopt php-sitemap when a PHP application needs to build typed sitemap entries and render several formats without tying its domain logic to a framework. Do not choose it when the application needs automatic URL discovery, crawl scheduling, search engine submission, or a runtime outside PHP. Check PHP 8.2 compatibility, the intended renderer, and the application route that will expose generated documents first.

Frequently asked questions

What is RumenDamyanov/php-sitemap used for?

It is a framework-agnostic PHP package for generating XML, TXT, HTML, Google News, and mobile sitemap documents. It supports ordinary URL entries as well as images, videos, translations, alternates, and Google News metadata.

How do I install RumenDamyanov/php-sitemap?

The README requires PHP 8.2 or later and Composer. Install it with `composer require rumenx/php-sitemap`; the README says no additional configuration is required.

Does RumenDamyanov/php-sitemap support Laravel and Symfony?

Yes. The README gives separate Laravel and Symfony examples. Laravel uses dependency injection and a view, while Symfony uses a controller that calls `renderXml()` and returns a `Response`.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. RumenDamyanov/php-sitemap on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rumendamyanov-php-sitemap.svg)](https://hysenlabs.com/projects/rumendamyanov-php-sitemap)

Was this useful?