File
Access componentsβ
\Co\IO::File() : File;
###API
public function getContents(string $path): Promise;
public function open(string $path, string $mode): Stream;
Overviewβ
Ripple provides asynchronous operation methods for files, allowing developers to read file contents and operate file streams through streams that do not block the process.
How to useβ
You can read the file in the following way
\Co\IO::File()->getContents(__FILE__)->then(function(string $value){
});
\Co\async(function(){
$value = \Co\await(
\Co\IO::File()->getContents(__FILE__)
);
});
You can also open a file stream in the following way
$stream = \Co\IO::File()->open('file.txt','r');
Stream follows the StreamInterface development of PSR specifications. For Stream operations, please see the Stream operation section.