PHPackages                             sallyx/redis-php-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. [File &amp; Storage](/categories/file-storage)
4. /
5. sallyx/redis-php-stream-wrapper

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

sallyx/redis-php-stream-wrapper
===============================

Implementation of streamWrapper using redis

v0.9.5(10y ago)644GNU 2PHPPHP &gt;=5.4.0

Since Nov 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sallyx/redis-php-stream-wrapper)[ Packagist](https://packagist.org/packages/sallyx/redis-php-stream-wrapper)[ Docs](http://github.org/sallyx/redis-php-stream-wrapper)[ RSS](/packages/sallyx-redis-php-stream-wrapper/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

redis-php-stream-wrapper
========================

[](#redis-php-stream-wrapper)

[![Build Status](https://camo.githubusercontent.com/4f4d36f6840de1cc84897427b9edd1776ff775bd7f3456f1c1d9b3e776d886fd/68747470733a2f2f7472617669732d63692e6f72672f73616c6c79782f72656469732d7068702d73747265616d2d777261707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sallyx/redis-php-stream-wrapper)[![Latest Stable Version](https://camo.githubusercontent.com/92f487878d24031cb54d7356b61730d1267bc2050a790144b1be75bfc5269e1c/68747470733a2f2f706f7365722e707567782e6f72672f73616c6c79782f72656469732d7068702d73747265616d2d777261707065722f762f737461626c65)](https://packagist.org/packages/sallyx/redis-php-stream-wrapper)[![License](https://camo.githubusercontent.com/817cbf9586d7ae862be9743f807d6e328a8649063163d86fbf26e89d4bdb522b/68747470733a2f2f706f7365722e707567782e6f72672f73616c6c79782f72656469732d7068702d73747265616d2d777261707065722f6c6963656e7365)](https://packagist.org/packages/sallyx/redis-php-stream-wrapper)

This package allows you to register redis server as [php stream wrapper](http://php.net/manual/en/intro.stream.php), so you will be able to use redis as as stream resource, i.e. 'redis://foo.txt'

Install
-------

[](#install)

### 1. Install phpredis/phpredis

[](#1-install-phpredisphpredis)

See [phpredis/phpredis](https://github.com/phpredis/phpredis).

### 2. Install packages by composer

[](#2-install-packages-by-composer)

```
$ composer require sallyx/redis-php-stream-wrapper
```

Setup
-----

[](#setup)

### All together

[](#all-together)

```
use Sallyx\StreamWrappers\Redis\ConnectorConfig;
use Sallyx\StreamWrappers\Redis\PathTranslator;
use Sallyx\StreamWrappers\Redis\Connector;
use Sallyx\StreamWrappers\Redis\FileSystem;
use Sallyx\StreamWrappers\Wrapper;

$config = new ConnectorConfig;
$translator = new PathTranslator('www.sallyx.org');
$connector = new Connector($config, $translator);
$fs = new FileSystem($connector);
Wrapper::register($fs);
```

### Step by step

[](#step-by-step)

#### 1. Create configuration

[](#1-create-configuration)

```
use Sallyx\StreamWrappers\Redis\ConnectorConfig;

$config = new ConnectorConfig( // all parameters are optional
    '127.0.0.1',
    $port = 6379,
    $timeout = 0,
    $persistent_id = NULL,
    $retry_interval = NULL
);
$config = new ConnectorConfig('/tmp/redis.sock'); // socket connection
```

#### 2. Create path translator

[](#2-create-path-translator)

```
use Sallyx\StreamWrappers\Redis\PathTranslator;
$translator = new PathTranslator($prefix = 'www.example.org');
```

Prefix is used for keys in redis server. For example file 'redis://foo.txt' will be saved in redis under key '[www.example.org://foo.txt](http://www.example.org://foo.txt)'.

#### 3. Create connector

[](#3-create-connector)

```
use Sallyx\StreamWrappers\Redis\Connector;
$connector = new Connector($config, $translator);
```

#### 4. Create redis file system

[](#4-create-redis-file-system)

```
use Sallyx\StreamWrappers\Redis\FileSystem;
$fs = new FileSystem($connector);
```

#### 5. Register as stream wrapper

[](#5-register-as-stream-wrapper)

```
use Sallyx\StreamWrappers\Wrapper;
Wrapper::register($fs,'redis');
```

*redis* is a scheme name of the wrapper ('redis:// ...')

#### 6. Profit

[](#6-profit)

```
mkdir('redis://foo');
file_put_contents('redis://foo/bar.txt', 'hello world');
echo file_get_contents('redis://foo/bar.txt');
...
```

Using with Nette
----------------

[](#using-with-nette)

If you do not know Nette, have a look at [www.nette.org](https://www.nette.org) or skip this block :)

First put [setup](/README.md#user-content-setup/) into app/bootstrap.php or anywhere before you want to use redis stream wrapper. After that you can use redis. For example for temp directory:

```
use Sallyx\StreamWrappers\Redis\Connector;
use Sallyx\StreamWrappers\Redis\ConnectorConfig;
use Sallyx\StreamWrappers\Redis\PathTranslator;
use Sallyx\StreamWrappers\Redis\FileSystem;
use Sallyx\StreamWrappers\Wrapper;

$cc = new ConnectorConfig();
$con = new Connector($cc, new PathTranslator('www.example.org'));
Wrapper::register(new FileSystem($co));
//...
$configurator->enableDebugger('redis://log');
$configurator->setTempDirectory('redis://temp');
//...
```

Optionally, you can use StreamWrappersExtension in app/config/config.local.neon, which show diagnostic panel in debugger bar.

```
extension:
        streamWrappers: Sallyx\Bridges\StreamWrappers\Nette\DI\StreamWrappersExtension

```

Now you could see your redis filesystem in the panel:

[![diagnostic panel](assets/diagnostic-panel.png)](assets/diagnostic-panel.png)

Known issues
------------

[](#known-issues)

If your PHP script ends unexpectedly, all locked files stay locked forever. You can unlock them in redis by this command:

```
HMSET www.example.org://foo/bar.txt lock_ex 0 lock_sh 0

```

Access rights are not supported (yet?). Functions like chmod(), chgrp(), chown() return always false.

Calling file\_put\_contents() with LOCK\_EX option triggers E\_WARNING "Exclusive locks may only be set for regular files" (This is a [PHP bug](https://bugs.php.net/bug.php?id=61201))

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Recently: every ~35 days

Total

6

Last Release

3751d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/521447ca813bc89fb2ef2780a06a5acf931c474beedcbed786838372a55d292a?d=identicon)[sallyx](/maintainers/sallyx)

---

Top Contributors

[![sallyx](https://avatars.githubusercontent.com/u/4263901?v=4)](https://github.com/sallyx "sallyx (31 commits)")

### Embed Badge

![Health badge](/badges/sallyx-redis-php-stream-wrapper/health.svg)

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

###  Alternatives

[ericnorris/amazon-s3-php

A lightweight and fast S3 client for PHP.

2147.0k](/packages/ericnorris-amazon-s3-php)

PHPackages © 2026

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