1. Go to this page and download the library: Download react/filesystem library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
react / filesystem example snippets
use React\Filesystem\Factory;
use React\Filesystem\Node\DirectoryInterface;
use React\Filesystem\Node\NodeInterface;
Factory::create()->detect(__DIR__)->then(function (DirectoryInterface $directory) {
return $directory->ls();
})->then(static function ($nodes) {
foreach ($nodes as $node) {
assert($node instanceof NodeInterface);
echo $node->name(), ': ', get_class($node), PHP_EOL;
}
echo '----------------------------', PHP_EOL, 'Done listing directory', PHP_EOL;
}, function (Throwable $throwable) {
echo $throwable;
});