Skip to content

ki7en/php-tail-file

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Tail File

Latest Version Maintenance Coverage

Efficiently tail a file from PHP - Reads the last x number of lines of a file (similar to Unix's tail command)

  • Great performance
  • It doesn't load the whole file to memory
  • Skips trailing new lines and empty lines
  • No dependencies
  • Tested on Linux, Windows and macOS
  • Compatible with PHP 7.4 and ^8

Usually used to read the last lines of:

  • CSV files
  • Log files
  • JSON files
  • text files

Installation

composer require jimenezmaximiliano/php-tail-file

Usage

$numberOfLines = 2;
$filePath = realpath("file.log");

$lines = Tail::tail($filePath, $numberOfLines);

// ["line 30", "line 31"]

About

Efficiently tail a file from PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 97.5%
  • Shell 2.5%