pastuhov/php-file-stream

Big file creation helper. May be used for sitemap.xml or YML files creation.

v1.0.2 2017-02-17 14:01 UTC

This package is not auto-updated.

Last update: 2021-09-18 01:14:58 UTC


README

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 kirill@pastukhov.su instead of using the issue tracker.

Credits

License

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