Skip to content

Latest commit

 

History

History
81 lines (54 loc) · 1.87 KB

README.md

File metadata and controls

81 lines (54 loc) · 1.87 KB

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.