PHPackages                             simp/streamwrapper - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. simp/streamwrapper

ActiveLibrary[File &amp; Storage](/categories/file-storage)

simp/streamwrapper
==================

This library is implements stream wrapper in php to provide clean file access

v1.0.3(1y ago)0924MITPHP

Since Feb 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/CHANCENY/stream-wrapper)[ Packagist](https://packagist.org/packages/simp/streamwrapper)[ RSS](/packages/simp-streamwrapper/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)DependenciesVersions (5)Used By (4)

Stream Wrapper Library
======================

[](#stream-wrapper-library)

This library provides a custom PHP **Stream Wrapper**, allowing you to register and use custom stream protocols (`public://` and `global://`) for file operations like reading and writing.

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

[](#installation)

1. **Clone the repository** or download the package into your project.
2. **Install dependencies** using Composer:

    ```
    composer require simp/streamwrapper
    ```

Usage
-----

[](#usage)

### 1. Registering Custom Stream Wrappers

[](#1-registering-custom-stream-wrappers)

The package uses `WrapperRegister` to register custom stream wrappers.

```
use Simp\StreamWrapper\Stream\GlobalStreamWrapper;
use Simp\StreamWrapper\WrapperRegister\WrapperRegister;

require_once "vendor/autoload.php";
require_once "PublicWrapper.php";

// Registering the global and public stream wrappers
WrapperRegister::register("global", GlobalStreamWrapper::class);
WrapperRegister::register("public", PublicWrapper::class);
```

### 2. Using the Registered Wrappers

[](#2-using-the-registered-wrappers)

Once registered, you can perform file operations using `global://` and `public://` as stream wrappers.

```
// Writing and reading using global wrapper
file_put_contents("global://example.txt", "\nLorem ipsum dolor sit amet\n", FILE_APPEND);
echo file_get_contents("global://example.txt");

// Writing and reading using public wrapper
file_put_contents("public://example.txt", "\nHello World!\n", FILE_APPEND);
echo file_get_contents("public://example.txt");
```

### 3. Customizing the Public Wrapper

[](#3-customizing-the-public-wrapper)

The `PublicWrapper.php` file extends the base `StreamWrapper` class, setting a custom `$stream_name` and `$base_path`:

```
class PublicWrapper extends \Simp\StreamWrapper\Stream\StreamWrapper
{
    protected string $stream_name = "public";
    protected string $basePath = "sites/public";
}
```

Modify the `$basePath` to change where files are stored when using `public://` paths.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Composer for dependency management

License
-------

[](#license)

This project is licensed under the MIT License.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance41

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

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

Total

4

Last Release

495d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25077813?v=4)[Chance007](/maintainers/Chance007)[@CHANCE007](https://github.com/CHANCE007)

---

Top Contributors

[![CHANCENY](https://avatars.githubusercontent.com/u/96126430?v=4)](https://github.com/CHANCENY "CHANCENY (8 commits)")

### Embed Badge

![Health badge](/badges/simp-streamwrapper/health.svg)

```
[![Health](https://phpackages.com/badges/simp-streamwrapper/health.svg)](https://phpackages.com/packages/simp-streamwrapper)
```

###  Alternatives

[venveo/craft-compress

Create smart zip files from Craft assets on the fly

124.7k](/packages/venveo-craft-compress)

PHPackages © 2026

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