17/07
2015
dev-master
9999999-dev
GPL
The Requires
composer require spartaksun/sitemap-php
use spartaksun\sitemap\generator as generator;
$storage = new generator\storage\MysqlStorage(); $storage->setKey('YOUR UNIQUE KEY FOR PROCESS');
$loader = new generator\loader\GuzzleLoader(); $parser = new generator\parser\HtmlParser();
$processor = new generator\SiteProcessor($storage, $loader, $parser); $generator = new generator\Generator($storage, $loader, $processor, new generator\writer\XmlWriter($storage) );
$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 ... });
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(); }
GPL