GithubHelp home page GithubHelp logo

Comments (4)

WyriHaximus avatar WyriHaximus commented on August 15, 2024

The README refers to installing ^0.2 but I didn't see that in Packagist and got an error when trying to install it.

Correct, the initial, big chunk, of work of the rewrite is done. v0.2.0 isn't out yet as a bunch of smaller improvements/bug fixes will need to be addressed. We didn't wait to wait to get the 80% of the features/changes available before working on the other 20% (which will probably take the other 80% of the time 😂 ).

But it looks like this was just rewritten 4 days ago! what a coincidence as I'm trying to use it for the first time in a project.

Please try it out and let us know how it worked for what you wanted to use it for. We need feedback like that.

That said, I have a question. Is this a valid alternative to using this project which is still experimental?

Yes, or well, I would. v0.1.x was experimental and I learned a lot from creating that version, including many many mistakes. v0.2 aims to take those lettings and mature this package into a stable version like our other components.

$path = '/foo/bar/file.css';
if (is_readable($path)) {
    $mimeType = $this->getMimeType($path);
    $fileStream = new ReadableResourceStream(fopen($path, 'rb'));
    $bodyStream = new ReadableBodyStream($fileStream, filesize($path));
    $headers = [
        'Content-Type' => $mimeType,
    ];
    return new \React\Http\Message\Response(200, $headers, $bodyStream);
}

I know already this example violates some of the async principles, for example these are all blocking: is_readable, fopen, filesize but this is only for a dev-convenience function not for production use. I have confirmed this works thus far, but wanted to see if this reactphp/filesystem project could be used as a more proper implementation. Thanks!

Try this, it doesn't stream the file's contents, but maybe we can add that in v0.2 (or v0.3 as well):

$path = '/foo/bar/file.css';
$this->getMimeType($path);
$filesystem->exists($path)->then(
    static fn (FileInterface $file): PromiseInterface => $file->getContents()
)->then(
    static fn (string $contents): ResponseInterface => new \React\Http\Message\Response(200, [
        'Content-Type' => $mimeType,
    ], $contents)
)

(I didn't check this code for mistakes or try to run it, bugs might be inside 😜 .)

P.S. I took the liberty of editing your comment and enable PHP syntax highlighting to your code example by appending php to the opening of that code block like so it is easier to read:

```php

from filesystem.

michaelbutler avatar michaelbutler commented on August 15, 2024

Hmm... alright so how would I install the latest development version to test? I tried running: composer require 'react/filesystem:dev-master' and got this composer error:

composer require 'react/filesystem:dev-master'                                                                                  2 ✘ 
./composer.json has been updated
Running composer update react/filesystem
Loading composer repositories with package information
Updating dependencies                                 
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - wyrihaximus/react-child-process-promise-closure 1.0.0 requires php ^7.0 -> your php version (8.1.2) does not satisfy that requirement.
    - react/filesystem dev-master requires wyrihaximus/react-child-process-promise-closure ^1.0 -> satisfiable by wyrihaximus/react-child-process-promise-closure[1.0.0].
    - Root composer.json requires react/filesystem dev-master -> satisfiable by react/filesystem[dev-master].


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

So looks like wyrihaximus/react-child-process-promise-closure has to be updated too?

from filesystem.

WyriHaximus avatar WyriHaximus commented on August 15, 2024

So looks like wyrihaximus/react-child-process-promise-closure has to be updated too?

Yes, working on that right now 👍 .

from filesystem.

WyriHaximus avatar WyriHaximus commented on August 15, 2024

@michaelbutler It should be requireable now

from filesystem.

Related Issues (20)

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.