reactphp / Filesystem
Licence: mit
Evented filesystem access.
Stars: ✭ 102
Labels
Projects that are alternatives of or similar to Filesystem
Zbox
Zero-details, privacy-focused in-app file system.
Stars: ✭ 1,185 (+1061.76%)
Mutual labels: filesystem
Dmon
Single header C99 portable library for monitoring directory changes.
Stars: ✭ 95 (-6.86%)
Mutual labels: filesystem
Polyfuse
A FUSE (Filesystem in Userspace) library for Rust
Stars: ✭ 76 (-25.49%)
Mutual labels: filesystem
Pyfilesystem2
Python's Filesystem abstraction layer
Stars: ✭ 1,256 (+1131.37%)
Mutual labels: filesystem
Vfsstream
vfsStream is a stream wrapper for a virtual file system that may be helpful in unit tests to mock the real file system. It can be used with any unit test framework, like PHPUnit or SimpleTest.
Stars: ✭ 1,302 (+1176.47%)
Mutual labels: filesystem
Laravel Storage
A simple filesystem abstraction package for Laravel 4.
Stars: ✭ 100 (-1.96%)
Mutual labels: filesystem
Dfc
Report file system space usage information with style (mirror repository)
Stars: ✭ 84 (-17.65%)
Mutual labels: filesystem
Fs extra
Expanding opportunities standard library std::fs and std::io
Stars: ✭ 95 (-6.86%)
Mutual labels: filesystem
Squashfs Tools Ng
A new set of tools and libraries for working with SquashFS images
Stars: ✭ 76 (-25.49%)
Mutual labels: filesystem
Rothko
An abstracted library for interacting with the file system, registry, etc.
Stars: ✭ 79 (-22.55%)
Mutual labels: filesystem
Wasi Fs Access
This is a demo shell powered by WebAssembly, WASI, Asyncify and File System Access API.
Stars: ✭ 98 (-3.92%)
Mutual labels: filesystem
React Restify
A ReactPHP framework to create RESTfull api
Stars: ✭ 87 (-14.71%)
Mutual labels: reactphp
Safe Stream
SafeStream: atomic and safe manipulation with files via native PHP functions.
Stars: ✭ 101 (-0.98%)
Mutual labels: filesystem
Docker Volume Ipfs
🐳 This is an open source volume plugin that allows using an ipfs filesystem as a volume.
Stars: ✭ 99 (-2.94%)
Mutual labels: filesystem
Cloudcmd
✨☁️📁✨ Cloud Commander file manager for the web with console and editor.
Stars: ✭ 1,332 (+1205.88%)
Mutual labels: filesystem
Filesystem
ReactPHP's evented asynchronous, non-blocking filesystem access library.
Table of Contents
Introduction
react/filesystem
is a package to power your application with asynchronous, non-blocking filesystem access. Asynchronous access is enabled by various adapters described below.
Adapters
- ChildProcessAdapter - Adapter using child processes to perform IO actions (default adapter if no extensions are installed)
Examples
Adding examples here over time.
Creating filesystem object
<?php
$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
File object
<?php
$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$file = $filesystem->file(__FILE__); // Returns a \React\Filesystem\Node\FileInterface compatible object
Reading files
$filesystem->getContents('test.txt')->then(function($contents) {
});
Which is a convenience method for:
$filesystem->file('test.txt')->open('r')->then(function($stream) {
return \React\Stream\BufferedSink::createPromise($stream);
})->then(function($contents) {
// ...
});
Which in it's turn is a convenience method for:
$filesystem->file('test.txt')->open('r')->then(function ($stream) use ($node) {
$buffer = '';
$deferred = new \React\Promise\Deferred();
$stream->on('data', function ($data) use (&$buffer) {
$buffer += $data;
});
$stream->on('end', function ($data) use ($stream, $deferred, &$buffer) {
$stream->close();
$deferred->resolve(&$buffer);
});
return $deferred->promise();
});
Writing files
Open a file for writing (w
flag) and write abcde
to test.txt
and close it. Create it (c
flag) when it doesn't exists and truncate it (t
flag) when it does.
$filesystem->file('test.txt')->open('cwt')->then(function ($stream) {
$stream->write('a');
$stream->write('b');
$stream->write('c');
$stream->write('d');
$stream->end('e');
});
Directory object
<?php
$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$dir = $filesystem->dir(__DIR__); // Returns a \React\Filesystem\Node\DirectoryInterface compatible object
List contents
$filesystem->dir(__DIR__)->ls()->then(function (array $list) {
foreach ($list as $node) {
echo $node->getPath(), PHP_EOL;
}
});
Install
The recommended way to install this library is through Composer. New to Composer?
This will install the latest supported version:
$ composer require react/filesystem:^0.1.1
License
React/Filesystem is released under the MIT license.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].