robier / sitemaps
Library for generating sitemaps
v0.3.5
2017-11-13 15:36 UTC
Requires
- php: ^7.1
Requires (Dev)
- codeclimate/php-test-reporter: ^0.4.4
- friendsofphp/php-cs-fixer: ^2.3
- phpunit/phpunit: ^6.1
README
PHP implementation of sitemaps.org protocol. This library was build using PHP Generators having in mind using as less memory as possible.
Supporting sitemap formats:
- XML sitemaps
- Text sitemaps
Library is also supporting GZip compression of generated sitemaps.
Usage
use Robier\Sitemaps\DataProvider; class Data implements DataProvider { public function fetch(): \Iterator { for($i = 1; $i <= 500000; $i++){ yield new Location('http://example.com/site-' . $i); } } }
use Robier\Sitemaps\Driver\XML; use Robier\Sitemaps\Generator; use Robier\Sitemaps\Processor\GZip; $writer = new XML('/tmp/', 'http://example.com/'); $generator = new Generator($writer); $generator->data('sitemap', new Data()); // gzip enable $generator->processor(new GZip()); foreach($generator as $item){ // // $item is instance of File/Contract }
Installation
composer require robier/sitemaps
Docker
For development you can use docker:
tests/docker/build tests/docker/run <command that will be send to docker contener> tests/docker/enter tests/docker/run xdebug <php script>
Todo
- Implement Atom/RSS format
- write tests
- add better documentation