PHP code example of sigmaphp / sigmaphp-filesystem

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

    

sigmaphp / sigmaphp-filesystem example snippets




$filesystem = new Filesystem();



$filesystem = new Filesystem();

$filesystem->create(
    '/var/www/project/example.txt',
    0644
);

$filesystem->write(
    '/var/www/project/example.txt',
    'Hello, SigmaPHP!'
);



$content = $filesystem->read(
    '/var/www/project/example.txt',
    0,
    1000
);

echo $content;

$files = $filesystem->list(
    '/var/www/project',
    true,
    true
);

if ($filesystem->exists('/var/www/project/config.php')) {
    echo 'File exists.';
}

if ($filesystem->dirHas('/var/www/project', 'config.php')) {
    echo 'config.php exists.';
}

$filesystem->create(
    '/var/www/project/example.txt',
    0644
);

$filesystem->rename(
    '/var/www/project/old.txt',
    '/var/www/project/new.txt'
);

$filesystem->copy(
    '/var/www/project/source.txt',
    '/var/www/project/backup/source.txt'
);

$filesystem->move(
    '/var/www/project/source.txt',
    '/var/www/project/archive/source.txt'
);

$filesystem->remove(
    '/var/www/project/example.txt'
);

$filesystem->write(
    '/var/www/project/example.txt',
    'Hello, SigmaPHP!'
);

$filesystem->append(
    '/var/www/project/example.txt',
    "\nAdditional content."
);

$content = $filesystem->read(
    '/var/www/project/example.txt',
    0,
    100
);

echo $content;

$filesystem->createDir(
    '/var/www/project/storage',
    0755,
    true
);

$filesystem->removeDir(
    '/var/www/project/storage/cache'
);