8fold/php-sitemap

A library for generating Sitemaps (XML)

2.0.0 2022-12-13 00:24 UTC

This package is auto-updated.

Last update: 2024-12-13 05:53:44 UTC


README

Generates valid XML document and sitemap elements based on the Sitemap protocol.

Installation

composer require 8fold/php-sitemap

Usage

You have received the required metadata in an array; could be the results of a database query.

use Eigthfold\Sitemap\Sitemap;

$sitemap = Sitemap::create('http://yourdomain.com');

$items = // your array of items

foreach ($items as $item) {
  $sitemap = $sitemap->addUrl(
    $item->path
  );
}

(string) $sitemap;

Details

Designed to fit within a loop.

Other

{links or descriptions or license, versioning, and governance}