Skip to content

Instantly share code, notes, and snippets.

@clue
Forked from carliedu/test.php
Last active May 7, 2021 12:39
Show Gist options
  • Save clue/bf9a6ab3906e12060606f3dcd4dcc002 to your computer and use it in GitHub Desktop.
Save clue/bf9a6ab3906e12060606f3dcd4dcc002 to your computer and use it in GitHub Desktop.
Get the result of file exist/no exits
<?php
use app\clFilesystem;
use React\MySQL\Factory;
require __DIR__ . '/vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$filesystem = \React\Filesystem\Filesystem::create($loop);
$file = "teste.txt";
f_existsFile($filesystem, $file)->then(function (string $result) use ($file) {
echo 'The file ['.$file.'] ['.$result."]\n";
});
//----- Final do LOOP
$loop->run();
// F U N C T I O N ////////////////////////////////////////////////////
/** @return \React\Promise\PromiseInterface<string> */
function f_existsFile($filesystem, $file): \React\Promise\PromiseInterface
{
return $filesystem->file($file)->exists()->then(function () {
return 'exists';
}, function () {
return 'was not found';
});
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment