PHP code example of icicleio / filesystem

1. Go to this page and download the library: Download icicleio/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/ */

    

icicleio / filesystem example snippets


#!/usr/bin/env php


e Icicle\File;
use Icicle\Loop;

Coroutine\create(function () {
    $path = __DIR__ . '/test.txt';

    // Create and open the file for reading and writing.
    $file = (yield File\open($path, 'w+'));

    try {
        // Write data to file.
        $written = (yield $file->write('testing'));
        
        printf("Wrote %d bytes to file.\n", $written);
        
        // Seek to beginning of file.
        yield $file->seek(0);
        
        // Read data from file.
        $data = (yield $file->read());
    } finally {
        $file->close();
    }
    
    printf("Read data from file: %s\n", $data);
    
    // Remove file.
    yield File\unlink($path);
})->done();

Loop\run();