PHPackages                             jalsoedesign/log-stream - 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. jalsoedesign/log-stream

ActiveLibrary

jalsoedesign/log-stream
=======================

0.5.2(3y ago)017MITPHPPHP ^7.4|^8.0

Since Feb 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/h2ooooooo/php-log-stream)[ Packagist](https://packagist.org/packages/jalsoedesign/log-stream)[ RSS](/packages/jalsoedesign-log-stream/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

LogStreamer
===========

[](#logstreamer)

Simple class that takes a path to a file and gives you the following features:

- `$stream->readLines(10)` to get the first 10 lines as a string
- `$stream->getLines(10)` to get the first 10 lines as an array
- `$stream->readLines(-10)` to get the last 10 lines as a string
- `$stream->getLines(-10)` to get the last 10 lines as an array
- `$stream->readIncremental()` to get new content added to the file (as it's written to)

Also gives you a simple way of seeking lines:

- `$stream->seekLines(10)` to seek to the end of the first 10 lines
- `$stream->seekLines(-10)` to seek to the beginning of the last 10 lines
- `$stream->seekReset()` to reset the seek to the first byte
- `$stream->seekEnd()` to seek to the end

**Note**: Using a negative offset will return the lines in reverse order (last line first). This can be prevented by setting `$returnOriginalOrder` to true as such: `$stream->readLines(-10, true)`

Installation
------------

[](#installation)

```
composer require jalsoedesign/log-streamer

```

Usage
-----

[](#usage)

### Instantiation

[](#instantiation)

```
use jalsoedesign\LogStream\LogStream;

require_once('vendor/autoload.php');

$stream = LogStream::fromPath('foo.txt');

// OR

$handle = fread('foo.txt', r);
$stream = new LogStream($handle);
```

### First 10 lines

[](#first-10-lines)

Read the first 10 lines of a file and print them as text

```
$stream = LogStream::fromPath('foo.txt');

echo 'The first 10 lines:' . PHP_EOL;
echo $stream->readLines(10);
```

Read the first 10 lines of a file and print them as an array

```
$stream = LogStream::fromPath('foo.txt');

echo 'The first 10 lines:' . PHP_EOL;
print_r($stream->getLines(10));
```

### Last 10 lines

[](#last-10-lines)

Read the last 10 lines of a file and print them as text

```
$stream = LogStream::fromPath('foo.txt');

echo 'The last 10 lines:' . PHP_EOL;
echo $stream->readLines(-10);
```

Read the last 10 lines of a file and print them as an array

```
$stream = LogStream::fromPath('foo.txt');

echo 'The last 10 lines:' . PHP_EOL;
print_r($stream->getLines(-10));
```

### Tail functionality

[](#tail-functionality)

Read the last 10 lines of a file and then continue to printing content when the file gets updated

```
$stream = LogStream::fromPath('foo.txt');

$logStream->seekLines(-10);

$running = true;

echo 'The last 10 lines as well as all new content:' . PHP_EOL;

do {
    echo $logStream->readIncremental();

    usleep(100000);
} while ($running);
```

Open a stream and only print the bytes that have been added to the file after opening

```
$stream = \LogStream::fromPath('foo.txt');

$logStream->seekReset();

$running = true;

echo 'New file content:' . PHP_EOL;

do {
    echo $logStream->readIncremental();

    usleep(100000);
} while ($running);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~0 days

Total

3

Last Release

1183d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b21c12f271f981851aa9e0190050713165d2eef8c4fad0c919628e2834a3c06?d=identicon)[jalsoedesign](/maintainers/jalsoedesign)

---

Top Contributors

[![h2ooooooo](https://avatars.githubusercontent.com/u/1726275?v=4)](https://github.com/h2ooooooo "h2ooooooo (4 commits)")

### Embed Badge

![Health badge](/badges/jalsoedesign-log-stream/health.svg)

```
[![Health](https://phpackages.com/badges/jalsoedesign-log-stream/health.svg)](https://phpackages.com/packages/jalsoedesign-log-stream)
```

PHPackages © 2026

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