PHP code example of aternos / io

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

    

aternos / io example snippets


use Aternos\IO\System\File\File;
use Aternos\IO\System\Directory\Directory;

$file = new File("path/to/file.txt");
$file->create();
$file->write("Hello World!");
$file->setPosition(0);
echo $file->read($file->getSize());
$file->delete();

$directory = new Directory("path/to/directory");
foreach ($directory->getChildrenRecursive() as $child) {
    echo $child->getPath() . PHP_EOL;
}
$directory->delete();

use Aternos\IO\System\FilesystemElement;

$element = FilesystemElement::getIOElementFromPath("path/to/element");

use Aternos\IO\Interfaces\Features\ReadInterface;
use Aternos\IO\Interfaces\Features\GetSizeInterface;

function readEntireFile(ReadInterface&GetSizeInterface $file): string {
    return $file->read($file->getSize());
}