spartaksun / sitemap-php
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:package
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: 5.0.0
- thepixeldeveloper/sitemap: 3.0.0
This package is auto-updated.
Last update: 2025-01-19 01:47:29 UTC
README
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(); }