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

1974d 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

[symfony/polyfill-php72

Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions

4.8k674.7M31](/packages/symfony-polyfill-php72)[symfony/polyfill-intl-icu

Symfony polyfill for intl's ICU-related data and classes

2.6k251.4M96](/packages/symfony-polyfill-intl-icu)[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.2k64.2M574](/packages/nette-php-generator)[consolidation/site-process

A thin wrapper around the Symfony Process Component that allows applications to use the Site Alias library to specify the target for a remote call.

5345.3M8](/packages/consolidation-site-process)[sycho/flarum-profile-cover

Adds the ability to add a cover image to a profile.

1836.6k](/packages/sycho-flarum-profile-cover)

PHPackages © 2026

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