2017 © Pedro Peláez
 

package sitemap-php

image

spartaksun/sitemap-php

  • Friday, July 17, 2015
  • by spartaksun
  • Repository
  • 1 Watchers
  • 1 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Sitemap generator (with parser).

Example of usage

composer require spartaksun/sitemap-php
use spartaksun\sitemap\generator as generator;

Choose type of storage:

$storage = new generator\storage\MysqlStorage();
$storage->setKey('YOUR UNIQUE KEY FOR PROCESS');

Choose type of loader and parser:

$loader = new generator\loader\GuzzleLoader();
$parser = new generator\parser\HtmlParser();

Initialize site processor:

$processor = new generator\SiteProcessor($storage, $loader, $parser);
$generator = new generator\Generator($storage, $loader, $processor,
    new generator\writer\XmlWriter($storage)
);

You may also process some events:

$storage->on(
    generator\storage\UniqueValueStorageInterface::EVENT_ADD_URLS, function ($event) {
    /* @var generator\Event $event */
    $params = $event->getParams();
    // do something ...
});
$generator->siteProcessor->on(
    generator\SiteProcessor::EVENT_PROCESSED_ALL, function () {
    // do something ...
});
$generator->writer->on(
    generator\writer\WriterInterface::EVENT_FINISH, function () {
    // do something ...
});

Then start generator:

try {
    $generator->generate(
        'http://site.ru' /* start page */,
        3 /* nesting level */,
        '/path/to/save.zip' /* path to save archive */
    );
} catch (generator\GeneratorException $e) {
    // do something ...
} catch (\Exception $e) {
    // do something ...
} finally {
    $storage->deInit();
}

The Versions

17/07 2015

dev-master

9999999-dev

  Sources   Download

GPL

The Requires