PHPackages                             icyapril/tail - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. icyapril/tail

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

icyapril/tail
=============

PHP library seeking to mimic the Unix tail program.

v1.0(9y ago)71071[1 issues](https://github.com/IcyApril/Tail/issues)BSD-3-ClausePHPPHP &gt;7.0.0

Since Sep 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/IcyApril/Tail)[ Packagist](https://packagist.org/packages/icyapril/tail)[ RSS](/packages/icyapril-tail/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/28aa9bae647972a98259ed97d8cba69a1f0a4581154aa5cc5f7a3ec3f57e9af2/68747470733a2f2f7472617669732d63692e6f72672f496379417072696c2f5461696c2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/IcyApril/Tail)[![Code Climate](https://camo.githubusercontent.com/a0958cf78e2ccfcd4f664a45228ef4c527fee56873b469ff78d5786c6633f914/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f496379417072696c2f5461696c2f6261646765732f6770612e737667)](https://codeclimate.com/github/IcyApril/Tail)[![Test Coverage](https://camo.githubusercontent.com/e149d34cad966cf258c704fc2d8230d374d4d9e18e9ffea0a826a70b7b1f4701/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f496379417072696c2f5461696c2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/IcyApril/Tail/coverage)[![Issue Count](https://camo.githubusercontent.com/8fe2880d71945c338c6b206f7f02fbc252ba1acaa38a02ef3e4967c127d7fd06/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f496379417072696c2f5461696c2f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/IcyApril/Tail)

PHP Tail Library
================

[](#php-tail-library)

A PHP Library for tailing files, supporting PHP 7.0 and above.

Currently, this library allows you to get the tail of a given file. Subsequent calls to the `getTail` function will return whatever has been appended since the last call.

Usage
-----

[](#usage)

Firstly let's create some random file with 3 lines of text.

```
$fileLocation = tempnam(sys_get_temp_dir(), 'tailTest');
file_put_contents($fileLocation, "Hello 1" . PHP_EOL . "Hello 2" . PHP_EOL . "Hello 3" . PHP_EOL);
```

Now we can instantiate the Tail Config class and inject it into the constructor of the Tail operator, then run the `getTail` function:

```
$config = new \IcyApril\Tail\Config($fileLocation);
$config->setLines(2);

$tail = new \IcyApril\Tail\Tail($config);
echo $tail->getTail();
```

The output of this will be the final two lines of the file we created:

```
Hello 2
Hello 3

```

Suppose we then append a line to the file:

```
file_put_contents($fileLocation, "Hello 4" . PHP_EOL, FILE_APPEND | LOCK_EX);
```

Running `getTail` again will yield `Hello 4`:

```
echo $tail->getTail();
// Hello 4
```

When to run getTail?
--------------------

[](#when-to-run-gettail)

You can decide when to call the `getTail` function by either using the `inotify` watcher or simply using polling with the `filemtime()` function.

Caveats
-------

[](#caveats)

- The output is based on line count. If your file has 15 lines to start with, then has 17; the last 2 will be displayed at the next `getTail` call.
- If a file is over-written and therefore has less than the amount of lines than it started with; the entire new file will be returned at the next `getTail` call.
- Obviously you need to have your own polling/monitoring to decide when to call `getTail`

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3571d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2026099?v=4)[Junade](/maintainers/IcyApril)[@IcyApril](https://github.com/IcyApril)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/icyapril-tail/health.svg)

```
[![Health](https://phpackages.com/badges/icyapril-tail/health.svg)](https://phpackages.com/packages/icyapril-tail)
```

###  Alternatives

[lootils/geo

A simple library for dealing with Earth geo coordinate manipulations.

1625.1k1](/packages/lootils-geo)[assurrussa/grid-view-table

Mini grid view table for laravel.

106.4k](/packages/assurrussa-grid-view-table)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
