jimenezmaximiliano / php-tail-file
Efficiently reads the last lines of a file like the tail command
Installs: 6 426
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- ext-dom: *
- phpunit/phpunit: ^8
This package is auto-updated.
Last update: 2024-04-19 20:57:07 UTC
README
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"]