PHPackages                             dcarbone/file-object-plus - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. dcarbone/file-object-plus

AbandonedArchivedLibrary[File &amp; Storage](/categories/file-storage)

dcarbone/file-object-plus
=========================

A simple extension of the PHP \\SplFileObject class

0.4.0(8y ago)06902MPL-2.0PHPPHP &gt;=5.4

Since Aug 17Pushed 8y ago1 watchersCompare

[ Source](https://github.com/dcarbone/file-object-plus)[ Packagist](https://packagist.org/packages/dcarbone/file-object-plus)[ Docs](https://github.com/dcarbone/file-object-plus)[ RSS](/packages/dcarbone-file-object-plus/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (2)Versions (10)Used By (2)

file-object-plus
================

[](#file-object-plus)

A simple extension of the PHP class [SplFileObject](http://php.net/manual/en/class.splfileobject.php)

Build status: [![Build Status](https://camo.githubusercontent.com/81e92d15ab33e255ea8c20d36234de17ae61f332458c6adc603fb50ab4ef9967/68747470733a2f2f7472617669732d63692e6f72672f64636172626f6e652f66696c652d6f626a6563742d706c75732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dcarbone/file-object-plus)

Basics:
-------

[](#basics)

This class is a very simple extension of the base PHP [SplFileObject](http://php.net/manual/en/class.splfileobject.php). As such, it has all the same functionality as the base class with a few minor additions.

### Countable Interface

[](#countable-interface)

I have implemented the [Countable](http://php.net/manual/en/class.countable.php) interface into this class. It utilizes my [FileHelper](https://github.com/dcarbone/helpers/blob/master/src/FileHelper.php) helper class to determine the count

To use, simply execute:

```
$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$count = count($fileObject);
echo $count;
```

To count lines that contain a term, execute:

```
$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$count = $fileObject->countLinesContaining('my term');
echo $count;
```

### Pagination

[](#pagination)

This class also implements some very simple pagination methods, modeled closely to how you would specify returning a portion of a database table.

To get a portion of a file irrespective of line content:

```
$fileObject = new DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$lines = $fileObject->paginateLines($offset, $limit);
var_dump($lines);
```

By default, blank lines are also returned. You may alternatively ignore these by passing in 4 parameters:

```
$fileObject = new \DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$search = null;
$includeEmpty = false;
$lines = $fileObject->paginateLines($offset, $limit, $search, $includeEmpty);
var_dump($lines);
```

If you wish to paginate through a file only matching lines that contain a certain term:

```
$fileObject = new \DCarbone\FileObjectPlus('myfile.txt');
$offset = 0;
$limit = 25;
$search = 'my term';
$lines = $fileObject->paginateLines($offset, $limit, $search);
```

*Note*: When searching, the fourth parameter is ignored

*Note*: Both pagination functions currently reset the underlying SplFileObject's internal line pointer.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

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 ~157 days

Recently: every ~315 days

Total

9

Last Release

3029d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.3.3

0.4.0PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/385c0c0eae1b51f1e81ee464ff6bfb3cce32589ac252ca68cc3a8aec2e3ada14?d=identicon)[dcarbone](/maintainers/dcarbone)

---

Top Contributors

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

---

Tags

phpsearchpaginationfileSplFileObjectfile iterator

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dcarbone-file-object-plus/health.svg)

```
[![Health](https://phpackages.com/badges/dcarbone-file-object-plus/health.svg)](https://phpackages.com/packages/dcarbone-file-object-plus)
```

###  Alternatives

[blueimp/jquery-file-upload

File Upload widget for jQuery.

141.5M18](/packages/blueimp-jquery-file-upload)[davaxi/vcalendar

PHP Class to generate VCalendar (ics) file

1180.8k](/packages/davaxi-vcalendar)

PHPackages © 2026

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