Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piotrpress/streamer
This library is a custom PHP Stream Wrapper, which provides write/read operations and stores the data in the memory.
https://github.com/piotrpress/streamer
file filesystem memory mock mockup protocol stream stream-wrapper streamwrapper temporary temporary-files url virtual virtual-file-system virtual-files
Last synced: 5 days ago
JSON representation
This library is a custom PHP Stream Wrapper, which provides write/read operations and stores the data in the memory.
- Host: GitHub
- URL: https://github.com/piotrpress/streamer
- Owner: PiotrPress
- License: gpl-3.0
- Created: 2021-10-25T22:01:46.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-15T09:25:40.000Z (over 2 years ago)
- Last Synced: 2024-11-08T22:57:26.108Z (6 days ago)
- Topics: file, filesystem, memory, mock, mockup, protocol, stream, stream-wrapper, streamwrapper, temporary, temporary-files, url, virtual, virtual-file-system, virtual-files
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.txt
Awesome Lists containing this project
README
# Streamer
![Tests](https://github.com/PiotrPress/streamer/actions/workflows/tests.yml/badge.svg)
This library is a custom [PHP Stream Wrapper](https://www.php.net/manual/en/class.streamwrapper.php), which provides write/read operations and stores the data in the memory.
**NOTE:** It is similar to `php:// memory`, with the difference that is reusable, i.e. after the stream has been closed you can reopen it and the written data are still there, similar to regular file. Take a look at example of usage below.
## Installation
```console
composer require piotrpress/streamer
```## Usage
```php
require __DIR__ . '/vendor/autoload.php';PiotrPress\Streamer::register( 'virtual' );
file_put_contents( 'virtual://test', 'Test data' );
echo file_get_contents( 'virtual://test' );
```## Supports
* `fopen()` modes: `r`, `r+`, `w`, `w+`, `a`, `a+`
* `fwrite()`, `fputs()` etc.
* `fread()`, `fgets()` etc.
* `file_get_contents()`, `file_put_contents()`
* `feof()`, `fseek()`, `ftell()`, `rewind()`
* `ftruncate()`
* `filesize()`
* `rename()`
* `unlink()`## Requirements
PHP >= `7.4` version.
## License
[GPL3.0](license.txt)