PHPackages                             mcoste/directory-files-stream-wrapper - 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. mcoste/directory-files-stream-wrapper

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

mcoste/directory-files-stream-wrapper
=====================================

A stream wrapper for PHP that allow to read from multiple files with one resource.

1.0.2(5y ago)04MITPHPPHP &gt;=7.1

Since Jun 16Pushed 4y ago1 watchersCompare

[ Source](https://github.com/MickaelCoste/DirectoryFilesStreamWrapper)[ Packagist](https://packagist.org/packages/mcoste/directory-files-stream-wrapper)[ RSS](/packages/mcoste-directory-files-stream-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (0)

DirectoryFilesStreamWrapper
===========================

[](#directoryfilesstreamwrapper)

Allow to read all files of a directory with a single resource object.

Install
-------

[](#install)

```
composer require mcoste/directory-files-stream-wrapper

```

Initialization
--------------

[](#initialization)

Before being able to use this stream wrapper, you have to register it. To do so, you have 2 ways.

### The easy way

[](#the-easy-way)

You can use the PHP [stream\_wrapper\_register()](https://www.php.net/manual/en/function.stream-wrapper-register.php) function:

```
stream_wrapper_register('protocol', DirectoryFilesStreamWrapper::class);

```

Replace 'protocol' by whatever valid string you want. See the [RFC 2396 (section 3.1: Scheme Component)](http://www.ietf.org/rfc/rfc2396.txt) for more details. You can simply use DirectoryFilesStreamWrapper::DEFAULT\_PROTOCOL\_NAME if you want.

### The very easy way

[](#the-very-easy-way)

An easier way is to call the static method DirectoryFilesStreamWrapper::register(). And that's it, you're good to go.

This method takes an optional parameter to specify the protocol name you want. By default, it uses DirectoryFilesStreamWrapper::DEFAULT\_PROTOCOL\_NAME.

Usage
-----

[](#usage)

With the registration completed, all you have to do is open a directory like so :

```
$resource = fopen('protocol://path/to/my/directory', 'r');

```

'protocol' must be replaced by the protocol name you have chosen ('directory-files' if you used DirectoryFilesStream::register() without parameters)

You can now use the resource as any other. For exemple :

```
$line = fgets($resource);

```

The files to be read are sorted by their names using the natural order, as defined by the PHP function [natsort()](https://www.php.net/manual/en/function.natsort.php).

Limitations
-----------

[](#limitations)

### Read only

[](#read-only)

This stream wrapper does not allow any other mode than 'r'. You can pass whatever mode you want to fopen(), **'r' will always be used.**This limitation is needed because 'r' is the only mode that makes sense in the context of this wrapper.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Total

3

Last Release

1978d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72f87893bb47cb0499e79ad3aa25c16be7e8c3fe2b80b462680f2e5778ff7c03?d=identicon)[mcoste](/maintainers/mcoste)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mcoste-directory-files-stream-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/mcoste-directory-files-stream-wrapper/health.svg)](https://phpackages.com/packages/mcoste-directory-files-stream-wrapper)
```

###  Alternatives

[devfaysal/laravel-bangladesh-geocode

7111.0k](/packages/devfaysal-laravel-bangladesh-geocode)[qoliber/m2-datapatchcreator

552.7k4](/packages/qoliber-m2-datapatchcreator)[zero1/module-pagebuilder-web-vitals

Provides functionality to include image dimensions, link labels and lazyload options to image to help improve Google's Web Vitals audits scores

1823.1k](/packages/zero1-module-pagebuilder-web-vitals)[codewithdennis/filament-simple-map

This package offers a straightforward and easy-to-use map action component for your Filament application.

365.8k](/packages/codewithdennis-filament-simple-map)[alirahimi/livewire-persian-datepicker

The Persian Datepicker component for Laravel Livewire

275.0k](/packages/alirahimi-livewire-persian-datepicker)[howdu/filament-record-switcher

Resource level navigation with search

1512.5k](/packages/howdu-filament-record-switcher)

PHPackages © 2026

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