Comments (4)
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 thisreactphp/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.
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.
So looks like
wyrihaximus/react-child-process-promise-closure
has to be updated too?
Yes, working on that right now 👍 .
from filesystem.
@michaelbutler It should be requireable now
from filesystem.
Related Issues (20)
- version 0.2.x HOT 4
- 0.2.x: error saving binary data. HOT 2
- fget truncate alternative? HOT 7
- Memory leak? HOT 1
- Error while running tail example HOT 2
- Tail example not working HOT 2
- Release for new changes HOT 3
- Delay when using Filesystem compared to ReadableResourceStream directly HOT 3
- Seek support on read operations HOT 1
- Add a synchronous adapter HOT 2
- Unable to extend React\Filesystem\ChildProcess\Proces
- PHP 8 support HOT 17
- ext-eio support HOT 7
- Tail example not work HOT 1
- 500 internal server error HOT 5
- PHP 7.3.27 compatibility HOT 3
- Filesystem `exists()` file method stopped working with last child-process versions HOT 2
- What should be the `getContents()` behavior when a file doesn't exist? HOT 2
- Reliability issues when writing multiple files at the same time HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filesystem.