-
-
Save clue/bf9a6ab3906e12060606f3dcd4dcc002 to your computer and use it in GitHub Desktop.
Get the result of file exist/no exits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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