PHP code example of spoova / iotext

1. Go to this page and download the library: Download spoova/iotext library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

spoova / iotext example snippets


use spoova\mi\core\classes\Bundle\IOText\IOTextStream;

IOTextStream::init(steps: 4);

IOTextStream::stream_view("Processing data...");
processData();

IOTextStream::stream_view("Extracting data...");
extractData();

IOTextStream::stream_view("Compressing file...");
compressFile();

IOTextStream::stream_view("Extraction complete...");

IOTextStream::close();

use spoova\mi\core\classes\Bundle\IOText\IOTextStream;
use spoova\mi\core\classes\Bundle\IOText\IOTextFile;

IOTextStream::init();

IOTextStream::stream_file('/path/to/progress.log', function (IOTextFile $file) {
    if ($file->isModified()) {
        IOTextStream::stream_view($file->textFromLine($file->lineCount()));
    }

    if (str_contains($file->text(), 'DONE')) {
        $file->stop();
    }
}, interval: 0.5);

IOTextStream::close();

IOTextStream::init(steps: 2);
IOTextStream::stream_view("Phase one, step one...");
IOTextStream::stream_view("Phase one, step two...");
IOTextStream::close();

IOTextStream::init(steps: 3); // completely fresh counters
IOTextStream::stream_view("Phase two, step one...");
// ...
IOTextStream::close();