PHPackages                             dcarbone/directory-iterator-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. [Search &amp; Filtering](/categories/search)
4. /
5. dcarbone/directory-iterator-plus

ActiveLibrary[Search &amp; Filtering](/categories/search)

dcarbone/directory-iterator-plus
================================

A simple extension of the PHP \\DirectoryIterator class

0.3.0(8y ago)3352MPL-2.0PHPPHP &gt;=5.4

Since Aug 14Pushed 8y ago2 watchersCompare

[ Source](https://github.com/dcarbone/directory-iterator-plus)[ Packagist](https://packagist.org/packages/dcarbone/directory-iterator-plus)[ Docs](https://github.com/dcarbone/directory-iterator-plus)[ RSS](/packages/dcarbone-directory-iterator-plus/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (9)Used By (0)

directory-iterator-plus
=======================

[](#directory-iterator-plus)

A simple extension of the PHP `\DirectoryIterator` class

**Build Status**: [![Build Status](https://camo.githubusercontent.com/87048624f4ba6d52cbba198fb85ad4328d84ae741e974095cde5cce491287e22/68747470733a2f2f7472617669732d63692e6f72672f64636172626f6e652f6469726563746f72792d6974657261746f722d706c75732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dcarbone/directory-iterator-plus)

Installation in your Composer App
---------------------------------

[](#installation-in-your-composer-app)

```
{
    "require": {
      "dcarbone/directory-iterator-plus" : "@stable"
    }
}
```

Concept
-------

[](#concept)

I had a need to be able to, relatively quickly, create a web interface which allowed the navigation of a directory of thousands of files.

I did not want to `glob()` my way through them, and I wanted a simple way to paginate and search through them.

This class met that need.

Usage
-----

[](#usage)

This class is an extension of the base PHP class [DirectoryIterator](http://php.net/manual/en/class.directoryiterator.php)and as such has all the same methods available, and to a great extent it's functionality is unchanged.

### New Methods

[](#new-methods)

I have provided several custom methods, most of which revolve around either getting a subset of files or determining the existence of a file within a directory

#### File and Directory Counting

[](#file-and-directory-counting)

You may retrieve these values after instantiation by calling `getFileCount()` or `getDirectoryCount()` methods.

I used to do some `exec` nonsense, but now I just be lazy and use `glob`.

#### Searching

[](#searching)

There are several options available to you:

- Determine existence by exact file / directory name
    - `containsFile($file)`
    - `containsDirectory($directory)`
- Determine existence by string search term
    - `containsFileLike($string[, $caseInsensitive = false])`
    - `containsDirectoryLike($string[, $caseInsensitive = false])`
- Get Count of files / directories by search term
    - `getFileCountLike($string)`
    - `getDirectoryCountLike($string)`

Each of the "Like" methods utilize PHP's [stripos](http://php.net/manual/en/function.stripos.php) function to determine if the passed value is contained wholly somewhere inside of the filename of a given file / directory.

#### File Pagination

[](#file-pagination)

There are currently two Pagination methods available:

- `paginateFileNames([$offset 0[, $limit = 25[, $search = null]]])`
- `paginateFiles([$offset 0[, $limit = 25[, $search = null]]])`

These methods are designed to operate similar to any other pagination code used against a database.

The `$search` term again uses the PHP [stripos](http://php.net/manual/en/function.stripos.php) method to determine matches.

The primary difference between these two methods is the contents of the returned array.

**`paginateFileNames()`**

This method will return an array of file names that match the input criteria

**`paginateFiles()`**

This method will return an array of `\DCarbone\DirectoryIteratorPlus` objects, each representing an individual file.

Comments and Suggestions
------------------------

[](#comments-and-suggestions)

If you find this library useful and have an idea of how it can be made better, please let me know!

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

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

Recently: every ~285 days

Total

8

Last Release

3018d ago

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

0.3.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 (40 commits)")

---

Tags

phpsearchdirectorydirectory paginationdirectory searchfile paginationdirectoryiteratordirectory iteratorfile search

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dcarbone-directory-iterator-plus/health.svg)

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

###  Alternatives

[centamiv/vektor

A native PHP Vector Database implementation with strict binary storage and Zero-RAM overhead.

3418.5k2](/packages/centamiv-vektor)[omaressaouaf/query-builder-criteria

Define reusable query criteria for filtering, sorting, search, field selection, and includes in Laravel Eloquent models

282.4k](/packages/omaressaouaf-query-builder-criteria)[apicart/fql

Filter Query Language

1110.6k](/packages/apicart-fql)

PHPackages © 2026

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