1

I'm trying to run this simple code on both PHP 7 and 8:

$loop = \React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$file = $filesystem->file('test.txt');
$file->getContents()->then(function ($contents) {
    echo $contents . PHP_EOL;
});
$loop->run();

After installing via composer, and yet it tells me that adapter is missing

Error:

PHP Fatal error:  Uncaught RuntimeException: No supported adapter found for this installation in \root\src\Filesystem.php:31
Stack trace:
#0 \root\try.php(6): React\Filesystem\Filesystem::create()
#1 {main}
  thrown in \root\vendor\react\filesystem\src\Filesystem.php on line 31
iTaMaR
  • 189
  • 2
  • 10
  • what is the exact error? – azibom May 02 '21 at 11:14
  • Could not reproduce your issue. 1) I installed the package and its dependencies using composer: `composer require react/filesystem:^0.1.1`, 2) Created a dummy `test.txt` file with a content, 3) And then I just added the ` – Petr Hejda May 02 '21 at 11:15
  • PHP Fatal error: Uncaught RuntimeException: No supported adapter found for this installation @azibom – iTaMaR May 02 '21 at 12:23
  • @PetrHejda I know how to use composer.. – iTaMaR May 02 '21 at 12:25
  • @iTaMaR Good for you. I was just telling you that using the information that you provided, I wasn't able to produce your issue, so possibly you might want to dig deeper and provide steps to reproduce your issue. – Petr Hejda May 02 '21 at 12:54

1 Answers1

1

Just look where and why the exception originated. (I will use react/filesystem:0.1.2 in code examples.)

The exception was thrown in React\Filesystem\Filesystem::create(). List of supported adapters is obtained from React\Filesystem\Filesystem::getSupportedAdapters().

This way you will come to methods which define whether given adapter is available on your platform:

  1. Method Eio\Adapter::isSupported():
    return substr(strtolower(PHP_OS), 0, 3) !== 'win' && function_exists('proc_open');
    This means your platform must not be Windows and proc_open() function must exist (i.e. it must not be disabled for security reasons by disable_functions directive).

  2. Method ChildProcess\Adapter::isSupported():
    return extension_loaded('eio');
    This means eio PHP extension must be installed, see installation instructions.

For me it also does not work as I am on Windows. For development with ReactPHP, it is generally a good idea to run PHP on Linux virtual machine for better compatibility.

user14967413
  • 1,264
  • 1
  • 6
  • 12