Skip to content

pastuhov/php-file-stream

Repository files navigation

php-file-stream

Build Status Scrutinizer Code Quality Code Coverage Total Downloads

A PHP class to generate sitemap files for large web-sites or YML (Yandex Market Language) files

Install

Via Composer

$ composer require pastuhov/php-file-stream

Features

  • transparent file splitting (multiple sitemaps)
  • fast and safe file replacement from tmp to public directory
  • dependencies: 0

Usage

Simple YML export

    $stream = new FileStream(
        '/tmp/export.yml'
    );

    $stream->write('<yml_catalog date="2010-04-01 17:00">');
    
    ...
    
    $stream->write('</yml_catalog>');

Advanced usage (large site sitemap, >10k urls)

    $stream = new FileStream(
        '/tmp/sitemap{count}.xml',
        '<urlset>',
        '</urlset>',
        10000
    );

    foreach ($urls as $url) {
        $stream->write(
            '<url><loc>' . $url . '</loc></url>' . PHP_EOL
        );
    }

Testing

$ composer test

or

$ phpunit

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

GNU General Public License, version 2. Please see License File for more information.