PHPackages                             creativefactoryrv/cartographer - 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. creativefactoryrv/cartographer

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

creativefactoryrv/cartographer
==============================

A powerful yet user-friendly PHP sitemap generator designed to create large, comprehensive sitemaps.

1.1.3(1y ago)014MITPHPPHP ^8.0.2

Since May 2Pushed 1y agoCompare

[ Source](https://github.com/CreativeFactory-di-Riva-Vigano/cartographer)[ Packagist](https://packagist.org/packages/creativefactoryrv/cartographer)[ RSS](/packages/creativefactoryrv-cartographer/feed)WikiDiscussions master Synced 1mo ago

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

Cartographer
============

[](#cartographer)

A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html), based on the work of Dan Horrigan ([tackk/cartographer](https://github.com/tackk/cartographer)).

This fork was originally created to address vulnerabilities arising from outdated dependencies and along the way became compatible with PHP 8, bringing the original features into the current context.

Cartographer can handle Sitemaps of any size. When generating sitemaps with more than 50,000 entries, the sitemap becomes a "map of maps" (i.e. nested sitemaps).

Supported PHP/HHVM Versions
---------------------------

[](#supported-phphhvm-versions)

- **PHP:** &gt;= 8.0.2

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

[](#installation)

### Composer CLI

[](#composer-cli)

```
composer require creativefactoryrv/cartographer:1.*

```

### composer.json

[](#composerjson)

```
{
    "require": {
        "creativefactoryrv/cartographer": "1.*"
    }
}
```

Basic Sitemap
-------------

[](#basic-sitemap)

If you have a sitemap that is under 50,000 items, you can just use the Sitemap class, and avoid the Sitemap Generator.

```
use CreativeFactoryRV\Cartographer\ChangeFrequency;
use CreativeFactoryRV\Cartographer\Sitemap;

$sitemap = new Sitemap();
$sitemap->add('http://foo.com', '2005-01-02', ChangeFrequency::WEEKLY, 1.0);
$sitemap->add('http://foo.com/about', '2005-01-01');

// Write it to a file
file_put_contents('sitemap.xml', (string) $sitemap);

// or simply echo it:
header ('Content-Type:text/xml');
echo $sitemap->toString();
```

### Output

[](#output)

```

    http://foo.com
    2005-01-02T00:00:00+00:00
    weekly
    1

    http://foo.com/about
    2005-01-01T00:00:00+00:00

```

Basic Sitemap Index
-------------------

[](#basic-sitemap-index)

If you want to build a Sitemap Index, separate from the Sitemap Generator, you can!

```
$sitemapIndex = new CreativeFactoryRV\Cartographer\SitemapIndex();

$sitemapIndex->add('http://foo.com/sitemaps/sitemap.1.xml', '2012-01-02');
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.2.xml', '2012-01-02');

// Write it to a file
file_put_contents('sitemap.xml', (string) $sitemapIndex);

// or simply echo it:
header ('Content-Type:text/xml');
echo $sitemapIndex->toString();
```

### Output

[](#output-1)

```

    http://foo.com/sitemaps/sitemap.1.xml
    2012-01-02T00:00:00+00:00

    http://foo.com/sitemaps/sitemap.2.xml
    2012-01-02T00:00:00+00:00

```

Sitemap Factory
---------------

[](#sitemap-factory)

The Sitemap Factory create Sitemaps and Sitemap Indexes and writes them to the Filesystem. It can be used to generate full Sitemaps with more than **50,000** URLs.

If more than one sitemap is generated, it will create a Sitemap Index automatically.

### Instantiating

[](#instantiating)

The factory uses [Flysystem](http://flysystem.thephpleague.com/) to write the sitemaps. This means you can write the sitemaps to Local Disk, S3, Dropbox, wherever you want.

```
