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

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

gsouf/cartographer
==================

A PHP sitemap generation tool.

1.2.2(8y ago)030MITPHPPHP &gt;=5.6

Since May 2Pushed 8y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (2)Versions (8)Used By (0)

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

[](#cartographer)

[![Latest Stable Version](https://camo.githubusercontent.com/7e97e8eec88e1ac0f265c6b09be245899770c05871253282abc095d68747d00e/68747470733a2f2f706f7365722e707567782e6f72672f7461636b6b2f636172746f677261706865722f76657273696f6e2e706e67)](https://packagist.org/packages/tackk/cartographer)[![Total Downloads](https://camo.githubusercontent.com/9117f52c8e2a8fd66c948dd26d60374e3593de7719f1d028fd2b8051b3608c6e/68747470733a2f2f706f7365722e707567782e6f72672f7461636b6b2f636172746f677261706865722f642f746f74616c2e706e67)](https://packagist.org/packages/tackk/cartographer)[![License](https://camo.githubusercontent.com/37cee678402b8c2858e4b11aba96e47d43a9b984f4fedd727a6f51734901b4ee/68747470733a2f2f706f7365722e707567782e6f72672f7461636b6b2f636172746f677261706865722f6c6963656e73652e706e67)](https://packagist.org/packages/tackk/cartographer)

[![Build Status](https://camo.githubusercontent.com/36fc0f85f5d532a780450a08943561e0c2607c640156c93c95d1e0aa5ec45854/68747470733a2f2f7472617669732d63692e6f72672f7461636b6b2f636172746f677261706865722e737667)](https://travis-ci.org/tackk/cartographer)[![Code Coverage](https://camo.githubusercontent.com/5d91b268329030bd1cb4c48a4177408fbef8de8cd4d88ecc4302bf8ae7e015c5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7461636b6b2f636172746f677261706865722f6261646765732f636f7665726167652e706e673f733d35353437613437666237653031346132366363346234336636393833326638326236373364386261)](https://scrutinizer-ci.com/g/tackk/cartographer/)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c36595ff4d35a2925a9ac39e8d5fc1077b9d4446849f8c9d8030dbf45da536f0/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7461636b6b2f636172746f677261706865722f6261646765732f7175616c6974792d73636f72652e706e673f733d34376239643938353037666133656135626539346566333635366133646535613562666636363264)](https://scrutinizer-ci.com/g/tackk/cartographer/)

---

**Note** : This is a fork of the original work that adds support for google image extension.

---

A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html).

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

- **GitHub Repo:**
- **Documentation:**

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

[](#supported-phphhvm-versions)

- **PHP:** &gt;= 5.4 (including 5.6 beta1)
- **HHVM:** &gt;= 3.0.0

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

[](#installation)

### Composer CLI

[](#composer-cli)

```
composer require tackk/cartographer:1.0.*

```

### composer.json

[](#composerjson)

```
{
    "require": {
        "tackk/cartographer": "1.0.*"
    }
}
```

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 Tackk\Cartographer\Sitemap;
use Tackk\Cartographer\ChangeFrequency;

$sitemap = new Tackk\Cartographer\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 Tackk\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. Is is 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.

```
