PHPackages                             syberisle/mock-php-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. syberisle/mock-php-stream

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

syberisle/mock-php-stream
=========================

Stream wrapper for mocking php://

2.0.0(1y ago)27.5k↓35%1MITPHPPHP &gt;=8.0CI passing

Since Jun 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SyberIsle/mock-php-stream)[ Packagist](https://packagist.org/packages/syberisle/mock-php-stream)[ RSS](/packages/syberisle-mock-php-stream/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

php:// Mock Library
===================

[](#php-mock-library)

[![Tests](https://github.com/syberisle/mock-php-stream/actions/workflows/tests.yml/badge.svg?event=push)](https://github.com/syberisle/mock-php-stream/actions/workflows/tests.yml/badge.svg?event=push)

This library is intended to be used to mock the `php://` stream wrapper.

It's highly recommended that you register/unregister this ONLY when you need it in a test. Otherwise, it could interfere with other built-in php streams during the course of it being registered.

**NOTE** Since version 2.0 the `php://temp[/maxmemory:NN]` and `php://memory` paths will behave as PHP does. The content written to them will not be available after the `stream_close` call. This means that `file_put_contents` and
`file_get_contents` cannot be used to read and write these two paths.

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

[](#installation)

`composer install syberisle/mock-php-stream`

Usage
-----

[](#usage)

Using this to test a Slim 3 app's ability to do direct file uploads, where the body IS the content, is now easier.

```
MockPhpStream::register();
file_put_contents('php://input', 'you test data');

$app = new Slim\App();
$app->post('', function ($request) {
    // direct file uploads
    $request->getBody()->detach();
    $from = fopen("php://input", 'r');
    $to   = fopen('/my/path/file', 'w');
    stream_copy_to_stream($from, $to);
    fclose($from);
    fclose($to);
});

MockPhpStream::unregister();
```

Security
--------

[](#security)

Using this in production could potentially cause problems as it overrides the built-in php stream functions.

Credits
-------

[](#credits)

The idea was based off on this blog article [Mocking php://input](http://news-from-the-basement.blogspot.com/2011/07/mocking-phpinput.html).

- [David Lundgren](https://github.com/dlundgren)
- [All Contributors](https://github.com/syberisle/pipeline/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance48

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~836 days

Total

4

Last Release

389d ago

Major Versions

1.1.0 → 2.0.02025-04-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/5eb9bc1606754fee81247bf5d4a6a4d7fb7cce1b3769de69a345c5c8e120211e?d=identicon)[dlundgren](/maintainers/dlundgren)

---

Top Contributors

[![dlundgren](https://avatars.githubusercontent.com/u/1322393?v=4)](https://github.com/dlundgren "dlundgren (12 commits)")[![pavlyuts](https://avatars.githubusercontent.com/u/6569739?v=4)](https://github.com/pavlyuts "pavlyuts (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/syberisle-mock-php-stream/health.svg)

```
[![Health](https://phpackages.com/badges/syberisle-mock-php-stream/health.svg)](https://phpackages.com/packages/syberisle-mock-php-stream)
```

PHPackages © 2026

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