2017 © Pedro Peláez
 

library sitemap

Sitemap and sitemap index builder

image

artemperepechai/sitemap

Sitemap and sitemap index builder

  • Wednesday, October 26, 2016
  • by artemPerepechai
  • Repository
  • 0 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 62 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Sitemap

Sitemap and sitemap index builder., (*1)

, (*2)

Features

  • Create sitemap files.
  • Create sitemap index files.
  • Automatically creates new file if 50000 URLs limit is reached.
  • Memory efficient buffer of configurable size.

Installation

in composer.json, (*3)

"require": { "artemPerepechai/sitemap" : "dev-master" }, "repositories": [ { "url": "https://github.com/artemPerepechai/sitemap", "type": "vcs" } ],, (*4)

After that, make sure your application autoloads Composer classes by including vendor/autoload.php., (*5)

How to use it

use samdark\sitemap\Sitemap;
use samdark\sitemap\Index;

// create sitemap
$sitemap = new Sitemap(__DIR__ . '/sitemap.xml');

// add some URLs
$sitemap->setLocation('http://example.com/mylink4')
        ->setLastModified(time())
        ->setFrequency(Sitemap::DAILY)
        ->setAlternateLanguage('en', 'http://example.com/en')
        ->setAlternateLanguage('de', 'http://example.com/de')
        ->setAlternateLanguage('fr', 'http://example.com/fr')
        ->setPriority(0.1)
        ->addItem();

// write it
$sitemap->write();

// get URLs of sitemaps written
$sitemapFileUrls = $sitemap->getSitemapUrls('http://example.com/');

// create sitemap for static files
$staticSitemap = new Sitemap(__DIR__ . '/sitemap_static.xml');

// add some URLs
$staticSitemap->setLocation('http://example.com/about')
              ->setLastModified(time())
              ->addItem();

$staticSitemap->setLocation('http://example.com/tos')
              ->setLastModified(time())
              ->addItem();

$staticSitemap->setLocation('http://example.com/jobs')
              ->setLastModified(time())
              ->addItem();

// write it
$staticSitemap->write();

// get URLs of sitemaps written
$staticSitemapUrls = $staticSitemap->getSitemapUrls('http://example.com/');

// create sitemap index file
$index = new Index(__DIR__ . '/sitemap_index.xml');

// add URLs
foreach ($sitemapFileUrls as $sitemapUrl) {
    $index->addSitemap($sitemapUrl);
}

// add more URLs
foreach ($staticSitemapUrls as $sitemapUrl) {
    $index->addSitemap($sitemapUrl);
}

// write it
$index->write();

Options

There are two methods to configre Sitemap instance:, (*6)

  • setMaxUrls($number). Sets maximum number of URLs to write in a single file. Default is 50000 which is the limit according to specification and most of existing implementations.
  • setBufferSize($number). Sets number of URLs to be kept in memory before writing it to file. Default is 1000. If you have more memory consider increasing it. If 1000 URLs doesn't fit, decrease it.
  • setUseIndent($bool). Sets if XML should be indented. Default is true.

Running tests

In order to run tests perform the following commands:, (*7)

composer install
phpunit

The Versions

26/10 2016

dev-master

9999999-dev https://github.com/artemPerepechai/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

by Artem Perepechai

sitemap

04/10 2016

2.0.6

2.0.6.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

sitemap

29/09 2016

2.0.5

2.0.5.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

sitemap

05/07 2016

2.0.4

2.0.4.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

sitemap

29/04 2016

2.0.3

2.0.3.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

sitemap

22/04 2016

dev-refactroring

dev-refactroring https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

sitemap

14/07 2015

2.0.2

2.0.2.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

sitemap

13/07 2015

2.0.1

2.0.1.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

sitemap

03/07 2015

2.0.0

2.0.0.0 https://github.com/samdark/sitemap

Sitemap and sitemap index builder

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

sitemap

29/06 2015

1.0.0

1.0.0.0 https://github.com/samdark/sitemap

Very simple abstraction for sitemap generation

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

sitemap