PHPackages                             cspray/stream-buffer-intercept - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. cspray/stream-buffer-intercept

ActiveLibrary[Testing &amp; Quality](/categories/testing)

cspray/stream-buffer-intercept
==============================

A test utility to help capture output sent to stream resources.

0.2.1(2y ago)3459[1 PRs](https://github.com/cspray/stream-buffer-intercept/pulls)2MITPHPPHP ^8.1CI failing

Since Mar 16Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/cspray/stream-buffer-intercept)[ Packagist](https://packagist.org/packages/cspray/stream-buffer-intercept)[ RSS](/packages/cspray-stream-buffer-intercept/feed)WikiDiscussions main Synced 3w ago

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

Stream Buffer Intercept
=======================

[](#stream-buffer-intercept)

A PHP testing utility designed to capture stream output and facilitate writing unit tests for systems that require writing to streams.

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

[](#installation)

```
composer require --dev cspray/stream-buffer-intercept
```

Usage Guide
-----------

[](#usage-guide)

There are scenarios where you may want to unit test some piece of code that writes to a stream. An example might be where you're writing tests to confirm log messages sent to `stdout` or `stderr`. The `Cspray\StreamBufferIntercept\StreamBuffer` class allows you to easily capture output sent to these streams, and others, to easily assert your expectations.

Let's take a look at a quick code example.

```
