PHP code example of jakubboucek / php-tail-stream

1. Go to this page and download the library: Download jakubboucek/php-tail-stream 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/ */

    

jakubboucek / php-tail-stream example snippets


use JakubBoucek\Tail\Tail;

Tail::lines(10)
    ->fromFile('path/to/your/file.txt')
    ->toOutput();

// Output the last 10 lines of the file


$f = fopen('path/to/your/file.txt', 'rb');

Tail::lines(10)
    ->fromStream($f)
    ->toOutput();

// Output the last 10 lines from the stream

 - toFile('path/to/your/output.txt'); // Write to file
 - toStream($stream);                 // Write to stream
 - toIterator();                      // Get iterator containting lines as strings