PHP code example of sun / filesystem

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

    

sun / filesystem example snippets


 

$filesystem = new Sun\Filesystem;
$filesystem->create(__DIR__.'/filename.txt', 'content');

$filesystem->delete(__DIR__.'/filename.txt');

$filesystem->update(__DIR__.'/filename.txt', ' more content');

$filesystem->get(__DIR__.'/filename.txt');

$filesystem->append(__DIR__.'/filename.txt', 'more content');

$filesystem->copy(__DIR__.'/filename.txt', __DIR__.'/filename2.txt' );

$filesystem->move(__DIR__.'/filename.txt', __DIR__.'/destination/filename.txt' );

$filesystem->size(__DIR__.'/filename.txt');

$filesystem->exists(__DIR__.'/filename.txt');

$filesystem->files(__DIR__.'/directoryName');

$filesystem->directories(__DIR__.'/directoryName');

$filesystem->createDirectory(__DIR__.'/directoryName');

$filesystem->deleteDirectory(__DIR__.'/directoryName');

$filesystem->cleanDirectory(__DIR__.'/directoryName');