/** * {@inheritdoc} */ public function scandir($path) { $this->reactor->addRef(); $promisor = new Deferred(); uv_fs_readdir($this->loop, $path, 0, function ($fh, $data) use($promisor, $path) { $this->reactor->delRef(); if (empty($fh)) { $promisor->fail(new \RuntimeException("Failed reading contents from {$path}")); } else { $promisor->succeed($data); } }); return $promisor->promise(); }
<?php uv_fs_readdir(uv_default_loop(), ".", 0, function ($result, $da) { var_dump($da); }); uv_run();
public function readDir($path, $callback) { uv_fs_readdir($this->getEventLoop(), $path, 0, $callback); }