Giter Club home page Giter Club logo

flystream's People

Contributors

elazar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flystream's Issues

Class 'League\Flysystem\InMemory\InMemoryFilesystemAdapter' not found

Hello,

I just tried the example in readme and it seems

use League\Flysystem\InMemory\InMemoryFilesystemAdapter;

$adapter = new InMemoryFilesystemAdapter();

causes the error Fatal error: Uncaught Error: Class 'League\Flysystem\InMemory\InMemoryFilesystemAdapter' not found.

I could not find the declaration for InMemoryFilesystemAdapter in the vendor directory downloaded with Composer.

I'm I missing something?

PSR Log > 1

Is there any intention to get a new major version here to support newer versions of the PSR Log interfaces?

Copying an empty file across streams doesn't seem to work?

touch('vol-public://foo.txt');
copy('vol-public://foo.txt', 'vol-private://bar.txt');

This creates an empty file in my public volume, but does not copy to private.

If I add content to one on public, then copy, it seems to work.

By contrast, doing this without stream wrappers works as expected.

touch('foo.txt');
copy('foo.txt', 'bar.txt');

Fatal error: Uncaught TypeError: fclose(): supplied resource is not a valid stream resource

Hello,

I tried the example in readme and got the following error.

Error

Fatal error: Uncaught TypeError: fclose(): supplied resource is not a valid stream resource in .../vendor/elazar/flystream/src/MemoryBuffer.php on line 40

TypeError: fclose(): supplied resource is not a valid stream resource in .../vendor/elazar/flystream/src/MemoryBuffer.php on line 40

Call Stack:
    0.0013     401440   1. {main}() .../scratch/flysystem-01.php:0
    0.2299    1156832   2. file_put_contents($filename = 'mem://foo/bar', $data = 'bay') .../scratch/flysystem-01.php:32
    0.2875    1161632   3. Elazar/Flystream/StreamWrapper->stream_close() .../scratch/flysystem-01.php:32
    0.2875    1161632   4. Elazar/Flystream/MemoryBuffer->close() .../vendor/elazar/flystream/src/StreamWrapper.php:162
    0.2875    1161632   5. fclose($stream = resource(50) of type (Unknown)) .../vendor/elazar/flystream/src/MemoryBuffer.php:40

Code

<?php
include( dirname( __DIR__ ) . '/vendor/autoload.php' );


use League\Flysystem\Filesystem;
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;

$adapter = new InMemoryFilesystemAdapter();
$filesystem = new Filesystem($adapter);

/**
 * 2. Register the filesystem with Flystream and associate it with a
 *    custom protocol (e.g. 'mem').
 */

use Elazar\Flystream\FilesystemRegistry;
use Elazar\Flystream\ServiceLocator;

$registry = ServiceLocator::get(FilesystemRegistry::class);
$registry->register('mem', $filesystem);

/**
 * 3. Interact with the filesystem instance using the custom protocol.
 */

mkdir('mem://foo');

$file = fopen('mem://foo/bar', 'w');
fwrite($file, 'baz');
fclose($file);

file_put_contents('mem://foo/bar', 'bay');

$contents = file_get_contents('mem://foo/bar');
// or
$contents = stream_get_contents('mem://foo/bar');

if (file_exists('mem://foo/bar')) {
    rename('mem://foo/bar', 'mem://foo/baz');
    touch('mem://foo/bar');
}

$file = fopen('mem://foo/baz', 'r');
fseek($file, 2);
$position = ftell($file);
ftruncate($file, 0);
fclose($file);

$dir = opendir('mem://foo');
while (($entry = readdir($dir)) !== false) {
    echo $entry, PHP_EOL;
}
closedir($dir);

unlink('mem://foo/bar');
unlink('mem://foo/baz');

rmdir('mem://foo');

// These won't have any effect because Flysystem doesn't support them.
chmod('mem://foo', 0755);
chown('mem://foo', 'root');
chgrp('mem://foo', 'root');

/**
 * 4. Optionally, unregister the filesystem with Flystream.
 */
$registry->unregister('mem');

Environment

  • PHP: 8.0.9
  • "elazar/flystream": "^0.3.0",
  • "league/flysystem": "^3.0.8",
  • "league/flysystem-memory": "^3.0"

Shared memory

Hi,

I have a question. I'm not familiar with streams.

I'm wondering whether it is possible to store a value in memory from one script and access the value from another script and vice versa. Since the example code in readme appears to deal with memories, is it perhaps possible somehow with this library without installing extra PHP extensions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.