Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,12 @@

.DS_Store
composer.lock
/test.php
/docker-compose.yml
/Dockerfile
/test-2.php
/sitemaps/
/logs/
/.config/
/.phpunit.result.cache
/sitemap.xml
14 changes: 0 additions & 14 deletions .scrutinizer.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

72 changes: 40 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
# Cartographer

[![Latest Stable Version](https://poser.pugx.org/tackk/cartographer/version.png)](https://packagist.org/packages/tackk/cartographer)
[![Total Downloads](https://poser.pugx.org/tackk/cartographer/d/total.png)](https://packagist.org/packages/tackk/cartographer)
[![License](https://poser.pugx.org/tackk/cartographer/license.png)](https://packagist.org/packages/tackk/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)).

[![Build Status](https://travis-ci.org/tackk/cartographer.svg)](https://travis-ci.org/tackk/cartographer)
[![Code Coverage](https://scrutinizer-ci.com/g/tackk/cartographer/badges/coverage.png?s=5547a47fb7e014a26cc4b43f69832f82b673d8ba)](https://scrutinizer-ci.com/g/tackk/cartographer/)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/tackk/cartographer/badges/quality-score.png?s=47b9d98507fa3ea5be94ef3656a3de5a5bff662d)](https://scrutinizer-ci.com/g/tackk/cartographer/)

A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html).
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 limit), the sitemap becomes a "map of maps" (i.e. nested sitemaps).

* **GitHub Repo:** [http://github.com/tackk/cartographer/](http://github.com/tackk/cartographer/)
* **Documentation:** [http://tackk.github.io/cartographer/](http://tackk.github.io/cartographer/)
entries, the sitemap becomes a "map of maps" (i.e. nested sitemaps).

## Supported PHP/HHVM Versions

* **PHP:** >= 5.4 (including 5.6 beta1)
* **HHVM:** >= 3.0.0
* **PHP:** >= 8.0.2

## Installation

### Composer CLI

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

### composer.json

``` json
{
"require": {
"tackk/cartographer": "1.0.*"
"creativefactoryrv/cartographer": "1.*"
}
}
```
Expand All @@ -45,10 +35,10 @@ If you have a sitemap that is under 50,000 items, you can just use the Sitemap c
Generator.

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

$sitemap = new Tackk\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');

Expand Down Expand Up @@ -83,7 +73,8 @@ echo $sitemap->toString();
If you want to build a Sitemap Index, separate from the Sitemap Generator, you can!

``` php
$sitemapIndex = new Tackk\Cartographer\SitemapIndex();
$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');

Expand Down Expand Up @@ -114,7 +105,7 @@ echo $sitemapIndex->toString();
## 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.
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.

Expand All @@ -126,13 +117,14 @@ means you can write the sitemaps to Local Disk, S3, Dropbox, wherever you want.
``` php
<?php

use CreativeFactoryRV\Cartographer\SitemapFactory;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Local\LocalFilesystemAdapter;

$adapter = new LocalAdapter(__DIR__.'/sitemaps');
$adapter = new LocalFilesystemAdapter(__DIR__ . '/sitemaps');
$filesystem = new Filesystem($adapter);
$sitemapFactory = new Tackk\Cartographer\SitemapFactory($filesystem);

$sitemapFactory = new SitemapFactory($filesystem);
```

### Base URL
Expand All @@ -155,19 +147,35 @@ its only parameter.
``` php
<?php

use CreativeFactoryRV\Cartographer\SitemapFactory;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Local\LocalFilesystemAdapter;

$adapter = new LocalAdapter(__DIR__.'/sitemaps');
$adapter = new LocalFilesystemAdapter(__DIR__ . '/sitemaps');
$filesystem = new Filesystem($adapter);
$sitemapFactory = new Tackk\Cartographer\SitemapFactory($filesystem);

// Create an Iterator of your URLs somehow.
$urls = get_url_iterator();
$sitemapFactory = new SitemapFactory($filesystem);
$sitemapFactory->setBaseUrl('http://foo.com/sitemaps/');

// Returns the URL to the main Sitemap/Index file
$mainSitemap = $sitemapFactory->createSitemap($urls);
$entries = [
[
'url' => 'http://example.com/page1',
'lastmod' => '2023-04-01',
'changefreq' => 'daily',
'priority' => '1.0'
],
[
'url' => 'http://example.com/page2',
'lastmod' => '2023-04-02',
'changefreq' => 'weekly',
'priority' => '0.8'
],
];

$iterator = new ArrayIterator($entries);

// Returns the URL to the main Sitemap/Index file
$mainSitemap = $sitemapFactory->createSitemap($iterator);
```

### Return Value
Expand All @@ -186,7 +194,7 @@ $files = $sitemapFactory->getFilesCreated();

## Running Tests

*This assumes you have ran `composer update`.*
*This assumes you ran `composer update`.*

From the repository root, run:

Expand Down
22 changes: 15 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
{
"name": "tackk/cartographer",
"description": "A PHP sitemap generation tool.",
"name": "creativefactoryrv/cartographer",
"description": "A powerful yet user-friendly PHP sitemap generator designed to create large, comprehensive sitemaps.",
"version": "1.1.3",
"keywords": ["sitemap", "generator"],
"license": "MIT",
"authors": [
{
"name": "Dan Horrigan",
"email": "dh@tackk.com"
},
{
"name": "Daniele Viganò"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"require-dev": {
"phpunit/phpunit": "4.0.*"
"phpunit/phpunit": "11.4.*"
},
"require": {
"php": ">=5.4",
"league/flysystem": "1.0.*"
"php": "^8.0.2",
"league/flysystem": "3.*",
"ext-dom": "*"
},
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Tackk\\Cartographer\\": "src/"
"CreativeFactoryRV\\Cartographer\\": "src/"
}
},
"extra": {
"note": "This fork includes modifications by Daniele Viganò to address a vulnerability caused by using an outdated version of League\\Flysystem as of 28/10/2024, based on the original work by Dan Horrigan."
}
}
23 changes: 12 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true"
stopOnFailure="false"
bootstrap="./vendor/autoload.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
<phpunit colors="true" stopOnFailure="false" bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="common">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>

<coverage>
<exclude>
<directory>./vendor</directory>
</blacklist>
</filter>
</phpunit>
</exclude>
</coverage>

<logging>
<testdoxHtml outputFile="logs/testdox.html"/>
<testdoxText outputFile="logs/testdox.txt"/>
</logging>
</phpunit>
Loading